[llvm] r280632 - [ORC] Clone module flags metadata into the globals module in the
Lang Hames via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 4 10:53:30 PDT 2016
Author: lhames
Date: Sun Sep 4 12:53:30 2016
New Revision: 280632
URL: http://llvm.org/viewvc/llvm-project?rev=280632&view=rev
Log:
[ORC] Clone module flags metadata into the globals module in the
CompileOnDemandLayer.
Also contains a tweak to the orc-lazy jit in LLI to enable the test case.
Added:
llvm/trunk/test/ExecutionEngine/OrcLazy/module-flags.ll
Modified:
llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
llvm/trunk/tools/lli/OrcLazyJIT.cpp
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h?rev=280632&r1=280631&r2=280632&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h Sun Sep 4 12:53:30 2016
@@ -364,10 +364,11 @@ private:
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.
@@ -387,6 +388,9 @@ private:
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
Modified: llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h?rev=280632&r1=280631&r2=280632&view=diff
==============================================================================
--- llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h (original)
+++ llvm/trunk/include/llvm/ExecutionEngine/Orc/IndirectionUtils.h Sun Sep 4 12:53:30 2016
@@ -415,6 +415,10 @@ void moveGlobalVariableInitializer(Globa
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.
Modified: llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp?rev=280632&r1=280631&r2=280632&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/Orc/IndirectionUtils.cpp Sun Sep 4 12:53:30 2016
@@ -241,5 +241,14 @@ GlobalAlias* cloneGlobalAliasDecl(Module
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.
Added: llvm/trunk/test/ExecutionEngine/OrcLazy/module-flags.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/ExecutionEngine/OrcLazy/module-flags.ll?rev=280632&view=auto
==============================================================================
--- llvm/trunk/test/ExecutionEngine/OrcLazy/module-flags.ll (added)
+++ llvm/trunk/test/ExecutionEngine/OrcLazy/module-flags.ll Sun Sep 4 12:53:30 2016
@@ -0,0 +1,13 @@
+; 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}
Modified: llvm/trunk/tools/lli/OrcLazyJIT.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lli/OrcLazyJIT.cpp?rev=280632&r1=280631&r2=280632&view=diff
==============================================================================
--- llvm/trunk/tools/lli/OrcLazyJIT.cpp (original)
+++ llvm/trunk/tools/lli/OrcLazyJIT.cpp Sun Sep 4 12:53:30 2016
@@ -18,7 +18,7 @@ using namespace llvm;
namespace {
- enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdErr,
+ enum class DumpKind { NoDump, DumpFuncsToStdOut, DumpModsToStdOut,
DumpModsToDisk };
cl::opt<DumpKind> OrcDumpKind("orc-lazy-debug",
@@ -30,9 +30,9 @@ namespace {
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 "
@@ -71,9 +71,9 @@ OrcLazyJIT::TransformFtor OrcLazyJIT::cr
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;
More information about the llvm-commits
mailing list