[llvm-dev] LLVM 10 LLJIT runConstructors()

Haoran Xu via llvm-dev llvm-dev at lists.llvm.org
Fri Oct 16 04:09:01 PDT 2020


Hello,

I have been struggling with making LLJIT runConstructors() working. I saw this
email thread
<https://lists.llvm.org/pipermail/llvm-dev/2019-March/131057.html> and
tried to replicate its logic:

> LLJIT LJ;
> // Add Modules.
> if (auto Err = LJ.runConstructors())
>   ... ; // report error.
>
> But it doesn't seem to work. The global constructors in llvm.global_ctor
doesn't seem to run (I added a printf in the constructor and it doesn't
seem to get executed).

However, the following code seems to work:

> CtorDtorRunner RR(J->getMainJITDylib());
>
> RR.add(getConstructors(*tsm.getModuleUnlocked()));
>
> exitOnError(J->addIRModule(std::move(tsm)));
>
> exitOnError(RR.run());


But I can't understand what's wrong with my previous approach by calling
LLJIT's runConstructor() method.
Would anyone kindly help on what part I'm missing? Thanks!

Best regards,
Haoran
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201016/cfb02374/attachment.html>


More information about the llvm-dev mailing list