mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-16 11:24:39 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220580 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user