summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLang Hames <lhames@gmail.com>2016-05-26 20:33:37 +0000
committerLang Hames <lhames@gmail.com>2016-05-26 20:33:37 +0000
commitf1d74b3e28f2993f25d39ce19a9f84322206feb2 (patch)
tree2a01b7d41cfd55c9708ee568310f5b07e62b6483
parenta5cefffc33b695313013a8763ffb67ae0f41b6cb (diff)
downloadbcm5719-llvm-f1d74b3e28f2993f25d39ce19a9f84322206feb2.tar.gz
bcm5719-llvm-f1d74b3e28f2993f25d39ce19a9f84322206feb2.zip
[Orc] Don't create empty globals modules in the CompileOnDemandLayer.
Global variables and aliases are emitted eagerly, but there may not be any in the incoming module. In that case, we can save some memory and compile time by not building, emitting and tracking an empty globals module. llvm-svn: 270908
-rw-r--r--llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
index 540700ff06e..87555c9ad01 100644
--- a/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
+++ b/llvm/include/llvm/ExecutionEngine/Orc/CompileOnDemandLayer.h
@@ -253,14 +253,8 @@ private:
Module &SrcM = LMResources.SourceModule->getResource();
- // Create the GlobalValues module.
+ // Create stub functions.
const DataLayout &DL = SrcM.getDataLayout();
- auto GVsM = llvm::make_unique<Module>((SrcM.getName() + ".globals").str(),
- SrcM.getContext());
- GVsM->setDataLayout(DL);
-
- // Create function stubs.
- ValueToValueMapTy VMap;
{
typename IndirectStubsMgrT::StubInitsMap StubInits;
for (auto &F : SrcM) {
@@ -292,6 +286,19 @@ 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())
+ return;
+
+ // Create the GlobalValues module.
+ auto GVsM = llvm::make_unique<Module>((SrcM.getName() + ".globals").str(),
+ SrcM.getContext());
+ GVsM->setDataLayout(DL);
+
+ ValueToValueMapTy VMap;
+
// Clone global variable decls.
for (auto &GV : SrcM.globals())
if (!GV.isDeclaration() && !VMap.count(&GV))
OpenPOWER on IntegriCloud