diff options
| author | Lang Hames <lhames@gmail.com> | 2016-08-29 00:54:29 +0000 |
|---|---|---|
| committer | Lang Hames <lhames@gmail.com> | 2016-08-29 00:54:29 +0000 |
| commit | 6b21751ba9f40dcc553b0d48033edec0f44ef32c (patch) | |
| tree | 66ece2f0dff487d9e17899d2b3677a9c32752f63 /llvm/tools/lli/OrcLazyJIT.h | |
| parent | 850feaf3b7d9e8ce60a2148a266fda20d9dc96c8 (diff) | |
| download | bcm5719-llvm-6b21751ba9f40dcc553b0d48033edec0f44ef32c.tar.gz bcm5719-llvm-6b21751ba9f40dcc553b0d48033edec0f44ef32c.zip | |
[Orc] Simplify LogicalDylib and move it back inside CompileOnDemandLayer. Also
switch to using one indirect stub manager per logical dylib rather than one per
input module.
LogicalDylib is a helper class used by the CompileOnDemandLayer to manage
symbol resolution between modules during lazy compilation. In particular, it
ensures that internal symbols resolve correctly even in the case where multiple
input modules contain the same internal symbol name (which must to be promoted
to external hidden linkage so that functions in any given module can be split
out by lazy compilation). LogicalDylib's resolution scheme (before this commit)
required one stub-manager per input module. This made recompilation of functions
(by adding a module containing a new definition) difficult, as the stub manager
for any given symbol was bound to the module that supplied the original
definition. By using one stubs manager for the whole logical dylib symbols can
be more easily replaced, although support for doing this is not included in this
patch (it will be implemented in a follow up).
llvm-svn: 279952
Diffstat (limited to 'llvm/tools/lli/OrcLazyJIT.h')
| -rw-r--r-- | llvm/tools/lli/OrcLazyJIT.h | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/llvm/tools/lli/OrcLazyJIT.h b/llvm/tools/lli/OrcLazyJIT.h index 71e0d839d27..80d2de361e8 100644 --- a/llvm/tools/lli/OrcLazyJIT.h +++ b/llvm/tools/lli/OrcLazyJIT.h @@ -68,14 +68,28 @@ public: if (M->getDataLayout().isDefault()) M->setDataLayout(DL); - // Record the static constructors and destructors. We have to do this before - // we hand over ownership of the module to the JIT. + // Rename, bump linkage and record static constructors and destructors. + // We have to do this before we hand over ownership of the module to the + // JIT. std::vector<std::string> CtorNames, DtorNames; - for (auto &M : Ms) { - for (auto Ctor : orc::getConstructors(*M)) - CtorNames.push_back(mangle(Ctor.Func->getName())); - for (auto Dtor : orc::getDestructors(*M)) - DtorNames.push_back(mangle(Dtor.Func->getName())); + { + unsigned CtorId = 0, DtorId = 0; + for (auto &M : Ms) { + for (auto Ctor : orc::getConstructors(*M)) { + std::string NewCtorName = ("$static_ctor." + Twine(CtorId++)).str(); + Ctor.Func->setName(NewCtorName); + Ctor.Func->setLinkage(GlobalValue::ExternalLinkage); + Ctor.Func->setVisibility(GlobalValue::HiddenVisibility); + CtorNames.push_back(mangle(NewCtorName)); + } + for (auto Dtor : orc::getDestructors(*M)) { + std::string NewDtorName = ("$static_dtor." + Twine(DtorId++)).str(); + Dtor.Func->setLinkage(GlobalValue::ExternalLinkage); + Dtor.Func->setVisibility(GlobalValue::HiddenVisibility); + DtorNames.push_back(mangle(Dtor.Func->getName())); + Dtor.Func->setName(NewDtorName); + } + } } // Symbol resolution order: |

