summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
diff options
context:
space:
mode:
authorDavide Italiano <davide@freebsd.org>2017-02-22 18:53:38 +0000
committerDavide Italiano <davide@freebsd.org>2017-02-22 18:53:38 +0000
commite122d6885af0cf0c990867c2c3fc6a9877510fe0 (patch)
treefde9f616989ffa34d7aa1612b7070d4675de4535 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
parent7ea5adfff4c73c76d52fe5aad3106244b0b0e301 (diff)
downloadbcm5719-llvm-e122d6885af0cf0c990867c2c3fc6a9877510fe0.tar.gz
bcm5719-llvm-e122d6885af0cf0c990867c2c3fc6a9877510fe0.zip
[ModuleSummaryAnalysis] Don't crash when referencing unnamed globals.
Instead, just be conservative as these are unfrequent enough. Thanks to Peter Collingbourne for the discussion about this on IRC. llvm-svn: 295861
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index 70b55674c07..950b8987c5b 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -447,6 +447,12 @@ ModuleSummaryIndex llvm::buildModuleSummaryIndex(
auto &Summary = GlobalList.second[0];
bool AllRefsCanBeExternallyReferenced =
llvm::all_of(Summary->refs(), [&](const ValueInfo &VI) {
+ // If a global value definition references an unnamed global,
+ // be conservative. They're valid IR so we don't want to crash
+ // when we encounter any of them but they're infrequent enough
+ // that we don't bother optimizing them.
+ if (!VI.getValue()->hasName())
+ return false;
return !CantBePromoted.count(VI.getValue()->getGUID());
});
if (!AllRefsCanBeExternallyReferenced) {
OpenPOWER on IntegriCloud