CompileOnDemandLayer.
Also contains a tweak to the orc-lazy jit in LLI to enable the test case.
llvm-svn: 280632
assert(!EC && "Error generating stubs");
}
- // If this module doesn't contain any globals or aliases we can bail out
- // early and avoid the overhead of creating and managing an empty globals
- // module.
- if (SrcM.global_empty() && SrcM.alias_empty())
+ // If this module doesn't contain any globals, aliases, or module flags then
+ // we can bail out early and avoid the overhead of creating and managing an
+ // empty globals module.
+ if (SrcM.global_empty() && SrcM.alias_empty() &&
+ !SrcM.getModuleFlagsMetadata())
return;
// Create the GlobalValues module.
if (!VMap.count(&A))
cloneGlobalAliasDecl(*GVsM, A, VMap);
+ // Clone the module flags.
+ cloneModuleFlagsMetadata(*GVsM, SrcM, VMap);
+
// Now we need to clone the GV and alias initializers.
// Initializers may refer to functions declared (but not defined) in this
GlobalAlias *cloneGlobalAliasDecl(Module &Dst, const GlobalAlias &OrigA,
ValueToValueMapTy &VMap);
+/// @brief Clone module flags metadata into the destination module.
+void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
+ ValueToValueMapTy &VMap);
+
} // End namespace orc.
} // End namespace llvm.
return NewA;
}
+void cloneModuleFlagsMetadata(Module &Dst, const Module &Src,
+ ValueToValueMapTy &VMap) {
+ auto *MFs = Src.getModuleFlagsMetadata();
+ if (!MFs)
+ return;
+ for (auto *MF : MFs->operands())
+ Dst.addModuleFlag(MapMetadata(MF, VMap));
+}
+
} // End namespace orc.
} // End namespace llvm.
--- /dev/null
+; RUN: lli -jit-kind=orc-lazy -orc-lazy-debug=mods-to-stdout %s | FileCheck %s
+;
+; CHECK: module-flags.ll.globals
+; CHECK-NOT: Module End
+; CHECK: The Answer is {{.*}}42
+
+define i32 @main() {
+ ret i32 0
+}
+
+!llvm.module.flags = !{!0}
+
+!0 = !{i32 1, !"The Answer is ", i32 42}
namespace {
- enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdErr,
+ enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdOut,
DumpModsToDisk };
cl::opt<DumpKind> OrcDumpKind("orc-lazy-debug",
clEnumValN(DumpKind::DumpFuncsToStdOut,
"funcs-to-stdout",
"Dump function names to stdout."),
- clEnumValN(DumpKind::DumpModsToStdErr,
- "mods-to-stderr",
- "Dump modules to stderr."),
+ clEnumValN(DumpKind::DumpModsToStdOut,
+ "mods-to-stdout",
+ "Dump modules to stdout."),
clEnumValN(DumpKind::DumpModsToDisk,
"mods-to-disk",
"Dump modules to the current "
return M;
};
- case DumpKind::DumpModsToStdErr:
+ case DumpKind::DumpModsToStdOut:
return [](std::unique_ptr<Module> M) {
- dbgs() << "----- Module Start -----\n" << *M
+ outs() << "----- Module Start -----\n" << *M
<< "----- Module End -----\n";
return M;