diff options
| author | Steven Wu <stevenwu@apple.com> | 2018-11-13 17:35:04 +0000 |
|---|---|---|
| committer | Steven Wu <stevenwu@apple.com> | 2018-11-13 17:35:04 +0000 |
| commit | fa43892d6fdf77e373dcf54f1c934380b8731df2 (patch) | |
| tree | 4908fa417e03b50a4713544230c993893fd38afb /llvm/lib/Transforms/IPO/FunctionImport.cpp | |
| parent | 77c17e26eaca06626a4ad1d9b2ccaba28d15b62f (diff) | |
| download | bcm5719-llvm-fa43892d6fdf77e373dcf54f1c934380b8731df2.tar.gz bcm5719-llvm-fa43892d6fdf77e373dcf54f1c934380b8731df2.zip | |
Revert "[ThinLTO] Internalize readonly globals"
This reverts commit 10c84a8f35cae4a9fc421648d9608fccda3925f2.
llvm-svn: 346768
Diffstat (limited to 'llvm/lib/Transforms/IPO/FunctionImport.cpp')
| -rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 45 |
1 files changed, 5 insertions, 40 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 60ca8e32897..1196dd0099b 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -294,8 +294,10 @@ static void computeImportForReferencedGlobals( LLVM_DEBUG(dbgs() << " ref -> " << VI << "\n"); for (auto &RefSummary : VI.getSummaryList()) - if (isa<GlobalVarSummary>(RefSummary.get()) && - canImportGlobalVar(RefSummary.get())) { + if (RefSummary->getSummaryKind() == GlobalValueSummary::GlobalVarKind && + !RefSummary->notEligibleToImport() && + !GlobalValue::isInterposableLinkage(RefSummary->linkage()) && + RefSummary->refs().empty()) { auto ILI = ImportList[RefSummary->modulePath()].insert(VI.getGUID()); // Only update stat if we haven't already imported this variable. if (ILI.second) @@ -822,25 +824,6 @@ void llvm::computeDeadSymbols( NumLiveSymbols += LiveSymbols; } -// Compute dead symbols and propagate constants in combined index. -void llvm::computeDeadSymbolsWithConstProp( - ModuleSummaryIndex &Index, - const DenseSet<GlobalValue::GUID> &GUIDPreservedSymbols, - function_ref<PrevailingType(GlobalValue::GUID)> isPrevailing, - bool ImportEnabled) { - computeDeadSymbols(Index, GUIDPreservedSymbols, isPrevailing); - if (ImportEnabled) { - Index.propagateConstants(GUIDPreservedSymbols); - } else { - // If import is disabled we should drop read-only attribute - // from all summaries to prevent internalization. - for (auto &P : Index) - for (auto &S : P.second.SummaryList) - if (auto *GVS = dyn_cast<GlobalVarSummary>(S.get())) - GVS->setReadOnly(false); - } -} - /// Compute the set of summaries needed for a ThinLTO backend compilation of /// \p ModulePath. void llvm::gatherImportedSummariesForModule( @@ -1037,22 +1020,6 @@ static Function *replaceAliasWithAliasee(Module *SrcModule, GlobalAlias *GA) { return NewFn; } -// Internalize values that we marked with specific attribute -// in processGlobalForThinLTO. -static void internalizeImmutableGVs(Module &M) { - for (auto &GV : M.globals()) { - // Skip GVs which have been converted to declarations - // by dropDeadSymbols. - if (GV.isDeclaration()) - continue; - if (auto *GVar = dyn_cast<GlobalVariable>(&GV)) - if (GVar->hasAttribute("thinlto-internalize")) { - GVar->setLinkage(GlobalValue::InternalLinkage); - GVar->setVisibility(GlobalValue::DefaultVisibility); - } - } -} - // Automatically import functions in Module \p DestModule based on the summaries // index. Expected<bool> FunctionImporter::importFunctions( @@ -1176,8 +1143,6 @@ Expected<bool> FunctionImporter::importFunctions( NumImportedModules++; } - internalizeImmutableGVs(DestModule); - NumImportedFunctions += (ImportedCount - ImportedGVCount); NumImportedGlobalVars += ImportedGVCount; @@ -1194,7 +1159,7 @@ static bool doImportingForModule(Module &M) { if (SummaryFile.empty()) report_fatal_error("error: -function-import requires -summary-file\n"); Expected<std::unique_ptr<ModuleSummaryIndex>> IndexPtrOrErr = - getModuleSummaryIndexForFile(SummaryFile); + getModuleSummaryIndexForFile(SummaryFile); if (!IndexPtrOrErr) { logAllUnhandledErrors(IndexPtrOrErr.takeError(), errs(), "Error loading file '" + SummaryFile + "': "); |

