summaryrefslogtreecommitdiffstats
path: root/llvm/tools/lli/lli.cpp
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2018-10-23 20:20:22 +0000
committerLang Hames <lhames@gmail.com>2018-10-23 20:20:22 +0000
commit841796decdcc7818736a7f7ba28fc636a6a497d2 (patch)
treeb7e3c462f0abda7025af1d9c762b94f4cbbd9f67 /llvm/tools/lli/lli.cpp
parent5ac28a0cfda2c5f620886ace6f3b882e2e9a571d (diff)
downloadbcm5719-llvm-841796decdcc7818736a7f7ba28fc636a6a497d2.tar.gz
bcm5719-llvm-841796decdcc7818736a7f7ba28fc636a6a497d2.zip
[ORC] Change how non-exported symbols are matched during lookup.
In the new scheme the client passes a list of (JITDylib&, bool) pairs, rather than a list of JITDylibs. For each JITDylib the boolean indicates whether or not to match against non-exported symbols (true means that they should be found, false means that they should not). The MatchNonExportedInJD and MatchNonExported parameters on lookup are removed. The new scheme is more flexible, and easier to understand. This patch also updates JITDylib search orders to be lists of (JITDylib&, bool) pairs to match the new lookup scheme. Error handling is also plumbed through the LLJIT class to allow regression tests to fail predictably when a lookup from a lazy call-through fails. llvm-svn: 345077
Diffstat (limited to 'llvm/tools/lli/lli.cpp')
-rw-r--r--llvm/tools/lli/lli.cpp46
1 files changed, 39 insertions, 7 deletions
diff --git a/llvm/tools/lli/lli.cpp b/llvm/tools/lli/lli.cpp
index f4585dc080d..c3c57e2cdee 100644
--- a/llvm/tools/lli/lli.cpp
+++ b/llvm/tools/lli/lli.cpp
@@ -115,6 +115,11 @@ namespace {
"rather than individual functions"),
cl::init(false));
+ cl::list<std::string>
+ JITDylibs("jd",
+ cl::desc("Specifies the JITDylib to be used for any subsequent "
+ "-extra-module arguments."));
+
// The MCJIT supports building for a target address space separate from
// the JIT compilation process. Use a forked process and a copying
// memory manager with IPC to execute using this functionality.
@@ -749,6 +754,8 @@ static orc::IRTransformLayer::TransformFunction createDebugDumper() {
llvm_unreachable("Unknown DumpKind");
}
+static void exitOnLazyCallThroughFailure() { exit(1); }
+
int runOrcLazyJIT(const char *ProgName) {
// Start setting up the JIT environment.
@@ -778,7 +785,11 @@ int runOrcLazyJIT(const char *ProgName) {
: None);
DataLayout DL = ExitOnErr(JTMB.getDefaultDataLayoutForTarget());
- auto J = ExitOnErr(orc::LLLazyJIT::Create(std::move(JTMB), DL, LazyJITCompileThreads));
+
+ auto J = ExitOnErr(orc::LLLazyJIT::Create(
+ std::move(JTMB), DL,
+ pointerToJITTargetAddress(exitOnLazyCallThroughFailure),
+ LazyJITCompileThreads));
if (PerModuleLazy)
J->setPartitionFunction(orc::CompileOnDemandLayer::compileWholeModule);
@@ -803,13 +814,32 @@ int runOrcLazyJIT(const char *ProgName) {
// Add the main module.
ExitOnErr(J->addLazyIRModule(std::move(MainModule)));
- // Add any extra modules.
- for (auto &ModulePath : ExtraModules) {
- auto M = parseIRFile(ModulePath, Err, *TSCtx.getContext());
- if (!M)
- reportError(Err, ProgName);
+ // Create JITDylibs and add any extra modules.
+ {
+ // Create JITDylibs, keep a map from argument index to dylib. We will use
+ // -extra-module argument indexes to determine what dylib to use for each
+ // -extra-module.
+ std::map<unsigned, orc::JITDylib *> IdxToDylib;
+ IdxToDylib[0] = &J->getMainJITDylib();
+ for (auto JDItr = JITDylibs.begin(), JDEnd = JITDylibs.end();
+ JDItr != JDEnd; ++JDItr) {
+ IdxToDylib[JITDylibs.getPosition(JDItr - JITDylibs.begin())] =
+ &J->createJITDylib(*JDItr);
+ }
- ExitOnErr(J->addLazyIRModule(orc::ThreadSafeModule(std::move(M), TSCtx)));
+ for (auto EMItr = ExtraModules.begin(), EMEnd = ExtraModules.end();
+ EMItr != EMEnd; ++EMItr) {
+ auto M = parseIRFile(*EMItr, Err, *TSCtx.getContext());
+ if (!M)
+ reportError(Err, ProgName);
+
+ auto EMIdx = ExtraModules.getPosition(EMItr - ExtraModules.begin());
+ assert(EMIdx != 0 && "ExtraModule should have index > 0");
+ auto JDItr = std::prev(IdxToDylib.lower_bound(EMIdx));
+ auto &JD = *JDItr->second;
+ ExitOnErr(
+ J->addLazyIRModule(JD, orc::ThreadSafeModule(std::move(M), TSCtx)));
+ }
}
// Add the objects.
@@ -837,6 +867,8 @@ int runOrcLazyJIT(const char *ProgName) {
AltEntryThreads.push_back(std::thread([EntryPoint]() { EntryPoint(); }));
}
+ J->getExecutionSession().dump(llvm::dbgs());
+
// Run main.
auto MainSym = ExitOnErr(J->lookup("main"));
typedef int (*MainFnPtr)(int, const char *[]);
OpenPOWER on IntegriCloud