You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[CIR][CIRGen] Add comdat support, enabling more dso_local and comdat LLVM tagging (llvm#751)
This PR implements:
1. Add comdat attribute as an optional attribute to CIR GlobalOp and
FuncOp, they are of the enum ComdatSelection type because it contains
all information we need. The
[llvm/include/llvm/IR/Comdat.h](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/include/llvm/IR/Comdat.h#L33)
has Comdat with selectionKind and its name, add users which are set of
pointers to GlobalObjects sharing the same name. The name is always the
name of global object (in CIR context, the GlobalOp or FuncOp), so we
don't need it. And the user set can always be collected when a
transformation looks up symbol table of the module, thus not really
necessary. Plus, it's not good for CIR to keep a set of pointers.
2. Thanks to comdat support, and adding call sites of setComdat similar
to what was in OG, we are able to implement canBenefitFromLocalAlias as
similar as possible to [GlobalValue::canBenefitFromLocalAlias()
](https://github.com/llvm/clangir/blob/4ea2ec38638391b964e88b77f926e0892b350e04/llvm/lib/IR/Globals.cpp#L112)
and this enable us to complete dso_local work by correctly setting
dso_local for functions.
3. I took back printing of dsolocal attribute of CIR, as I would fix
128+ test cases instead of 36-37 of tests (mostly adding dso_local to
function prototype line in LLVM check) in this PR. printing dsolocal
attribute is not really necessary as llvm IR would verify it for us.
4. LLVM lowering of Comdat for GlobalOp
Things left to next/future PR
1. I'd like to extend setComdat to other parts of CG like Vtable, etc.
2. LLVM lowering of comdat for FuncOp
0 commit comments