Add llvm.mlir.global_ctors and global_dtors ops and their translation
support to LLVM global_ctors/global_dtors global variables.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Nice, thanks!
Do you have an idea of what would it take to also model the data field?
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | ||
---|---|---|
1165 | Loaded? | |
1173 | The syntax in examples does not correspond to the assembly format below. | |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
642 | How does this behave when the same symbol is listed more the once in the constructor list? Should we add a check? |
The data field in the corresponding LLVM globals has too low-level semantics and surrounding context attached to it to be able to meaningfully describe in MLIR at this stage -- it's connected to object file sections and linkers, and is sensitive to binary formats.
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
---|---|---|
642 | The LLVM global ctors/dtors list itself doesn't appear to care about duplicates. They are just sorted based on priority and called (so potentially multiple times based on a quick read of the LLVM code). But I actually missed adding verifiers. We should have been checking for example that the sizes of array attributes matched. |
mlir/lib/Target/LLVMIR/ModuleTranslation.cpp | ||
---|---|---|
642 | I see, thanks! Let's please have verifiers for the equal number of elements in the arrays and also for symbol references referring to symbols that are actually defined as functions. |
Add verifiers to check symbol and priority list sizes, and for valid
defined functions. Switch priority to i32.
Address remaining review comments.
mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td | ||
---|---|---|
1165 | Fixed. |
Loaded?