diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-24 18:13:04 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2014-10-24 18:13:04 +0000 |
| commit | d4bcefc7d9ff16710b2509e494614b5c08013567 (patch) | |
| tree | b3737bb77e7daf33769e961cbb2cdf4e94d99faa /llvm/lib/Linker | |
| parent | f924e11967750e5e269e063a22fc495799cfab6d (diff) | |
| download | bcm5719-llvm-d4bcefc7d9ff16710b2509e494614b5c08013567.tar.gz bcm5719-llvm-d4bcefc7d9ff16710b2509e494614b5c08013567.zip | |
Don't ever call materializeAllPermanently during LTO.
To do this, change the representation of lazy loaded functions.
The previous representation cannot differentiate between a function whose body
has been removed and one whose body hasn't been read from the .bc file. That
means that in order to drop a function, the entire body had to be read.
llvm-svn: 220580
Diffstat (limited to 'llvm/lib/Linker')
| -rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 35 |
1 files changed, 14 insertions, 21 deletions
diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index 0313e2b8a7e..510813ad972 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -672,21 +672,10 @@ bool ModuleLinker::getComdatResult(const Comdat *SrcC, LinkFromSrc); } -// FIXME: Duplicated from the gold plugin. This should be refactored somewhere. -static bool isDeclaration(const GlobalValue &V) { - if (V.hasAvailableExternallyLinkage()) - return true; - - if (V.isMaterializable()) - return false; - - return V.isDeclaration(); -} - bool ModuleLinker::shouldLinkFromSource(const GlobalValue &Dest, const GlobalValue &Src) { - bool SrcIsDeclaration = isDeclaration(Src); - bool DestIsDeclaration = isDeclaration(Dest); + bool SrcIsDeclaration = Src.isDeclarationForLinker(); + bool DestIsDeclaration = Dest.isDeclarationForLinker(); // FIXME: Make datalayout mandatory and just use getDataLayout(). DataLayout DL(Dest.getParent()); @@ -1635,14 +1624,16 @@ bool ModuleLinker::run() { SF->getPrefixData(), ValueMap, RF_None, &TypeMap, &ValMaterializer)); } - // Skip if no body (function is external) or materialize. - if (SF->isDeclaration()) { - if (!SF->isMaterializable()) - continue; + // Materialize if needed. + if (SF->isMaterializable()) { if (SF->Materialize(&ErrorMsg)) return true; } + // Skip if no body (function is external). + if (SF->isDeclaration()) + continue; + linkFunctionBody(DF, SF); SF->Dematerialize(); } @@ -1684,14 +1675,16 @@ bool ModuleLinker::run() { &ValMaterializer)); } - // Materialize if necessary. - if (SF->isDeclaration()) { - if (!SF->isMaterializable()) - continue; + // Materialize if needed. + if (SF->isMaterializable()) { if (SF->Materialize(&ErrorMsg)) return true; } + // Skip if no body (function is external). + if (SF->isDeclaration()) + continue; + // Erase from vector *before* the function body is linked - linkFunctionBody could // invalidate I. LazilyLinkFunctions.erase(I); |

