mirror of
https://github.com/RPCSX/llvm.git
synced 2025-01-26 06:14:42 +00:00
[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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270908 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
746036c22a
commit
f8e8d07f49
@ -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))
|
||||
|
Loading…
x
Reference in New Issue
Block a user