[Mlir-commits] [mlir] [mlir][ExecutionEngine] Add support for global constructors and destructors (PR #78070)

Fabian Mora llvmlistbot at llvm.org
Sun Jan 14 08:46:07 PST 2024


fabianmcg wrote:

> what is the mechanism that calls `ctor` and `dtor`? I believe that the `initialize`/`deinitialize` function calls that this patch adds are part of LLVM's Orc/LLJIT but I am missing the next link(s) until the `ctor`/`dtor` functions

The `initialize` function calls all the initializers in the `JITDylib` see [LLJIT.cpp#L227 `GenericLLVMIRPlatformSupport`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp#L128) and  [LLJIT.cpp#L227 `initialize`](https://github.com/llvm/llvm-project/blob/main/llvm/lib/ExecutionEngine/Orc/LLJIT.cpp#L227). Now, in this case `ctor` is an initializer because it's marked as such:
```
llvm.mlir.global_ctors {ctors = [@ctor], priorities = [0 : i32]}
```
That operation translates to `llvm.global_ctors`, see [LLVM Lang Ref](https://llvm.org/docs/LangRef.html#the-llvm-global-ctors-global-variable) for more information.


https://github.com/llvm/llvm-project/pull/78070


More information about the Mlir-commits mailing list