namespace {
- enum class JITKind { MCJIT, OrcLazy };
+ enum class JITKind { MCJIT, Orc, OrcLazy };
enum class JITLinkerKind { Default, RuntimeDyld, JITLink };
cl::opt<std::string>
"jit-kind", cl::desc("Choose underlying JIT kind."),
cl::init(JITKind::MCJIT),
cl::values(clEnumValN(JITKind::MCJIT, "mcjit", "MCJIT"),
+ clEnumValN(JITKind::Orc, "orc", "Orc JIT"),
clEnumValN(JITKind::OrcLazy, "orc-lazy",
"Orc-based lazy JIT.")));
}
Error loadDylibs();
-int runOrcLazyJIT(const char *ProgName);
+int runOrcJIT(const char *ProgName);
void disallowOrcOptions();
//===----------------------------------------------------------------------===//
ExitOnErr(loadDylibs());
- if (UseJITKind == JITKind::OrcLazy)
- return runOrcLazyJIT(argv[0]);
- else
+ if (UseJITKind == JITKind::MCJIT)
disallowOrcOptions();
+ else
+ return runOrcJIT(argv[0]);
+ // Old lli implementation based on ExecutionEngine and MCJIT.
LLVMContext Context;
// Load the bitcode...
return orc::ThreadSafeModule(std::move(M), std::move(TSCtx));
}
-int runOrcLazyJIT(const char *ProgName) {
+int runOrcJIT(const char *ProgName) {
// Start setting up the JIT environment.
// Parse the main module.
std::make_unique<LLIBuiltinFunctionGenerator>(GenerateBuiltinFunctions,
Mangle));
+ // Regular modules are greedy: They materialize as a whole and trigger
+ // materialization for all required symbols recursively. Lazy modules go
+ // through partitioning and they replace outgoing calls with reexport stubs
+ // that resolve on call-through.
+ auto AddModule = [&](orc::JITDylib &JD, orc::ThreadSafeModule M) {
+ return UseJITKind == JITKind::OrcLazy ? J->addLazyIRModule(JD, std::move(M))
+ : J->addIRModule(JD, std::move(M));
+ };
+
// Add the main module.
- ExitOnErr(J->addLazyIRModule(std::move(MainModule)));
+ ExitOnErr(AddModule(J->getMainJITDylib(), std::move(MainModule)));
// Create JITDylibs and add any extra modules.
{
assert(EMIdx != 0 && "ExtraModule should have index > 0");
auto JDItr = std::prev(IdxToDylib.lower_bound(EMIdx));
auto &JD = *JDItr->second;
- ExitOnErr(J->addLazyIRModule(JD, std::move(M)));
+ ExitOnErr(AddModule(JD, std::move(M)));
}
for (auto EAItr = ExtraArchives.begin(), EAEnd = ExtraArchives.end();