diff options
author | Reid Kleckner <rnk@google.com> | 2019-07-04 00:03:30 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2019-07-04 00:03:30 +0000 |
commit | f7e52fbdb5a7af8ea0808e98458b497125a5eca1 (patch) | |
tree | e7ff60e16fd3a7c1b066d2ff8d3f4152525205dc /llvm/lib/Transforms | |
parent | ec4be576554c8be1c0a47cb78d411c3f42ba69e9 (diff) | |
download | bcm5719-llvm-f7e52fbdb5a7af8ea0808e98458b497125a5eca1.tar.gz bcm5719-llvm-f7e52fbdb5a7af8ea0808e98458b497125a5eca1.zip |
Revert [ThinLTO] Optimize writeonly globals out
This reverts r365040 (git commit 5cacb914758c7f436b47c8362100f10cef14bbc4)
Speculatively reverting, since this appears to have broken check-lld on
Linux. Partial analysis in https://crbug.com/981168.
llvm-svn: 365097
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/FunctionImport.cpp | 12 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/FunctionImportUtils.cpp | 13 |
2 files changed, 11 insertions, 14 deletions
diff --git a/llvm/lib/Transforms/IPO/FunctionImport.cpp b/llvm/lib/Transforms/IPO/FunctionImport.cpp index 62c7fbd0722..9207f5fe0ef 100644 --- a/llvm/lib/Transforms/IPO/FunctionImport.cpp +++ b/llvm/lib/Transforms/IPO/FunctionImport.cpp @@ -850,16 +850,14 @@ void llvm::computeDeadSymbolsWithConstProp( bool ImportEnabled) { computeDeadSymbols(Index, GUIDPreservedSymbols, isPrevailing); if (ImportEnabled) { - Index.propagateAttributes(GUIDPreservedSymbols); + Index.propagateConstants(GUIDPreservedSymbols); } else { - // If import is disabled we should drop read/write-only attribute + // 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())) { + if (auto *GVS = dyn_cast<GlobalVarSummary>(S.get())) GVS->setReadOnly(false); - GVS->setWriteOnly(false); - } } } @@ -1066,7 +1064,7 @@ static Function *replaceAliasWithAliasee(Module *SrcModule, GlobalAlias *GA) { // Internalize values that we marked with specific attribute // in processGlobalForThinLTO. -static void internalizeGVsAfterImport(Module &M) { +static void internalizeImmutableGVs(Module &M) { for (auto &GV : M.globals()) // Skip GVs which have been converted to declarations // by dropDeadSymbols. @@ -1199,7 +1197,7 @@ Expected<bool> FunctionImporter::importFunctions( NumImportedModules++; } - internalizeGVsAfterImport(DestModule); + internalizeImmutableGVs(DestModule); NumImportedFunctions += (ImportedCount - ImportedGVCount); NumImportedGlobalVars += ImportedGVCount; diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp index c9cc0990f23..8e80ee2c549 100644 --- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp +++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp @@ -229,11 +229,11 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) { } } - // Mark read/write-only variables which can be imported with specific - // attribute. We can't internalize them now because IRMover will fail - // to link variable definitions to their external declarations during - // ThinLTO import. We'll internalize read-only variables later, after - // import is finished. See internalizeGVsAfterImport. + // Mark read-only variables which can be imported with specific attribute. + // We can't internalize them now because IRMover will fail to link variable + // definitions to their external declarations during ThinLTO import. We'll + // internalize read-only variables later, after import is finished. + // See internalizeImmutableGVs. // // If global value dead stripping is not enabled in summary then // propagateConstants hasn't been run. We can't internalize GV @@ -241,8 +241,7 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) { if (!GV.isDeclaration() && VI && ImportIndex.withGlobalValueDeadStripping()) { const auto &SL = VI.getSummaryList(); auto *GVS = SL.empty() ? nullptr : dyn_cast<GlobalVarSummary>(SL[0].get()); - // At this stage "maybe" is "definitely" - if (GVS && (GVS->maybeReadOnly() || GVS->maybeWriteOnly())) + if (GVS && GVS->isReadOnly()) cast<GlobalVariable>(&GV)->addAttribute("thinlto-internalize"); } |