summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorMehdi Amini <mehdi.amini@apple.com>2016-03-19 00:40:31 +0000
committerMehdi Amini <mehdi.amini@apple.com>2016-03-19 00:40:31 +0000
commit8d05185a26ecbd1079b43651c427508a6156f1ea (patch)
tree8795898d6605a0f3e13c3d4e3dda784c2a08dddd /llvm/lib/Transforms/Utils
parent67e03a1ce6df29e880727dbf38eb5db250a1a6ae (diff)
downloadbcm5719-llvm-8d05185a26ecbd1079b43651c427508a6156f1ea.tar.gz
bcm5719-llvm-8d05185a26ecbd1079b43651c427508a6156f1ea.zip
Rework linkInModule(), making it oblivious to ThinLTO
Summary: ThinLTO is relying on linkInModule to import selected function. However a lot of "magic" was hidden in linkInModule and the IRMover, who would rename and promote global variables on the fly. This is moving to an approach where the steps are decoupled and the client is reponsible to specify the list of globals to import. As a consequence some test are changed because they were relying on the previous behavior which was importing the definition of *every* single global without control on the client side. Now the burden is on the client to decide if a global has to be imported or not. Reviewers: tejohnson Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D18122 From: Mehdi Amini <mehdi.amini@apple.com> llvm-svn: 263863
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/FunctionImportUtils.cpp36
1 files changed, 13 insertions, 23 deletions
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
index eceb0850941..c4561cd23ea 100644
--- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -18,30 +18,20 @@ using namespace llvm;
/// Checks if we should import SGV as a definition, otherwise import as a
/// declaration.
bool FunctionImportGlobalProcessing::doImportAsDefinition(
- const GlobalValue *SGV, DenseSet<const GlobalValue *> *FunctionsToImport) {
- auto *GA = dyn_cast<GlobalAlias>(SGV);
- if (GA) {
+ const GlobalValue *SGV, DenseSet<const GlobalValue *> *GlobalsToImport) {
+
+ // For alias, we tie the definition to the base object. Extract it and recurse
+ if (auto *GA = dyn_cast<GlobalAlias>(SGV)) {
if (GA->hasWeakAnyLinkage())
return false;
const GlobalObject *GO = GA->getBaseObject();
if (!GO->hasLinkOnceODRLinkage())
return false;
return FunctionImportGlobalProcessing::doImportAsDefinition(
- GO, FunctionsToImport);
+ GO, GlobalsToImport);
}
- // Always import GlobalVariable definitions, except for the special
- // case of WeakAny which are imported as ExternalWeak declarations
- // (see comments in FunctionImportGlobalProcessing::getLinkage). The linkage
- // changes described in FunctionImportGlobalProcessing::getLinkage ensure the
- // correct behavior (e.g. global variables with external linkage are
- // transformed to available_externally definitions, which are ultimately
- // turned into declarations after the EliminateAvailableExternally pass).
- if (isa<GlobalVariable>(SGV) && !SGV->isDeclaration() &&
- !SGV->hasWeakAnyLinkage())
- return true;
- // Only import the function requested for importing.
- auto *SF = dyn_cast<Function>(SGV);
- if (SF && FunctionsToImport->count(SF))
+ // Only import the globals requested for importing.
+ if (GlobalsToImport->count(SGV))
return true;
// Otherwise no.
return false;
@@ -51,8 +41,8 @@ bool FunctionImportGlobalProcessing::doImportAsDefinition(
const GlobalValue *SGV) {
if (!isPerformingImport())
return false;
- return FunctionImportGlobalProcessing::doImportAsDefinition(
- SGV, FunctionsToImport);
+ return FunctionImportGlobalProcessing::doImportAsDefinition(SGV,
+ GlobalsToImport);
}
bool FunctionImportGlobalProcessing::doPromoteLocalToGlobal(
@@ -198,8 +188,6 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {
GV.setLinkage(getLinkage(&GV));
if (!GV.hasLocalLinkage())
GV.setVisibility(GlobalValue::HiddenVisibility);
- if (isModuleExporting())
- NewExportedValues.insert(&GV);
} else
GV.setLinkage(getLinkage(&GV));
@@ -231,7 +219,9 @@ bool FunctionImportGlobalProcessing::run() {
return false;
}
-bool llvm::renameModuleForThinLTO(Module &M, const ModuleSummaryIndex &Index) {
- FunctionImportGlobalProcessing ThinLTOProcessing(M, Index);
+bool llvm::renameModuleForThinLTO(
+ Module &M, const ModuleSummaryIndex &Index,
+ DenseSet<const GlobalValue *> *GlobalsToImport) {
+ FunctionImportGlobalProcessing ThinLTOProcessing(M, Index, GlobalsToImport);
return ThinLTOProcessing.run();
}
OpenPOWER on IntegriCloud