[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
This commit is contained in:
parent
a5cefffc33
commit
f1d74b3e28
|
@ -253,14 +253,8 @@ private:
|
||||||
|
|
||||||
Module &SrcM = LMResources.SourceModule->getResource();
|
Module &SrcM = LMResources.SourceModule->getResource();
|
||||||
|
|
||||||
// Create the GlobalValues module.
|
// Create stub functions.
|
||||||
const DataLayout &DL = SrcM.getDataLayout();
|
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;
|
typename IndirectStubsMgrT::StubInitsMap StubInits;
|
||||||
for (auto &F : SrcM) {
|
for (auto &F : SrcM) {
|
||||||
|
@ -292,6 +286,19 @@ private:
|
||||||
assert(!EC && "Error generating stubs");
|
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.
|
// Clone global variable decls.
|
||||||
for (auto &GV : SrcM.globals())
|
for (auto &GV : SrcM.globals())
|
||||||
if (!GV.isDeclaration() && !VMap.count(&GV))
|
if (!GV.isDeclaration() && !VMap.count(&GV))
|
||||||
|
|
Loading…
Reference in New Issue