summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Utils
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2019-11-01 10:31:02 -0700
committerTeresa Johnson <tejohnson@google.com>2019-11-01 13:57:01 -0700
commit16ec00eee7e348767f4393f189044f87f6374031 (patch)
tree461b376de97091e27677e3f6cf6028a54a1eacdb /llvm/lib/Transforms/Utils
parentf5d935c16777c39142043c429ccebb65259dc767 (diff)
downloadbcm5719-llvm-16ec00eee7e348767f4393f189044f87f6374031.tar.gz
bcm5719-llvm-16ec00eee7e348767f4393f189044f87f6374031.zip
Recommit "[ThinLTO] Handle GUID collision in import global processing""
This recommits cc0b9647b76178bc3869bbfff80535ad86366472 which was reverted in d39d1a2f87aca3cfabe58ecfa5146879baa70096. I added a fix for an issue found when testing via distributed ThinLTO, and added a test case for that failure.
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r--llvm/lib/Transforms/Utils/FunctionImportUtils.cpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
index 76b4635ad50..5b68efbb6d8 100644
--- a/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
+++ b/llvm/lib/Transforms/Utils/FunctionImportUtils.cpp
@@ -239,11 +239,22 @@ void FunctionImportGlobalProcessing::processGlobalForThinLTO(GlobalValue &GV) {
// propagateConstants hasn't been run. We can't internalize GV
// in such case.
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()))
- cast<GlobalVariable>(&GV)->addAttribute("thinlto-internalize");
+ if (GlobalVariable *V = dyn_cast<GlobalVariable>(&GV)) {
+ // We can have more than one local with the same GUID, in the case of
+ // same-named locals in different but same-named source files that were
+ // compiled in their respective directories (so the source file name
+ // and resulting GUID is the same). Find the one in this module.
+ // Handle the case where there is no summary found in this module. That
+ // can happen in the distributed ThinLTO backend, because the index only
+ // contains summaries from the source modules if they are being imported.
+ // We might have a non-null VI and get here even in that case if the name
+ // matches one in this module (e.g. weak or appending linkage).
+ auto* GVS = dyn_cast_or_null<GlobalVarSummary>(
+ ImportIndex.findSummaryInModule(VI, M.getModuleIdentifier()));
+ // At this stage "maybe" is "definitely"
+ if (GVS && (GVS->maybeReadOnly() || GVS->maybeWriteOnly()))
+ V->addAttribute("thinlto-internalize");
+ }
}
bool DoPromote = false;
OpenPOWER on IntegriCloud