summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
diff options
context:
space:
mode:
authorTeresa Johnson <tejohnson@google.com>2016-04-27 14:19:38 +0000
committerTeresa Johnson <tejohnson@google.com>2016-04-27 14:19:38 +0000
commitdf5ef8711f5b5b374144b32eecb9f2bacdecfb8a (patch)
tree1c90654b021ce91545ec9d67f45c7d3afb6e2b69 /llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
parent221e2c61ec3b83add0d54b41eaee650b9ca6b386 (diff)
downloadbcm5719-llvm-df5ef8711f5b5b374144b32eecb9f2bacdecfb8a.tar.gz
bcm5719-llvm-df5ef8711f5b5b374144b32eecb9f2bacdecfb8a.zip
[ThinLTO] Refine fix to avoid renaming of uses in inline assembly.
Summary: Refine the workaround from r266877 that attempts to prevent renaming of locals in inline assembly, so that in addition to looking for a llvm.used local value, that there is at least one inline assembly call in the module. Otherwise, debug functions added to the llvm.used can block importing/exporting unnecessarily. Reviewers: joker.eph Subscribers: llvm-commits, joker.eph Differential Revision: http://reviews.llvm.org/D19573 llvm-svn: 267717
Diffstat (limited to 'llvm/lib/Analysis/ModuleSummaryAnalysis.cpp')
-rw-r--r--llvm/lib/Analysis/ModuleSummaryAnalysis.cpp20
1 files changed, 14 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index ed1b57124b6..e33ec29a955 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -19,6 +19,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/IR/CallSite.h"
#include "llvm/IR/Dominators.h"
+#include "llvm/IR/InstIterator.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/ValueSymbolTable.h"
#include "llvm/Pass.h"
@@ -119,10 +120,10 @@ ModuleSummaryIndexBuilder::ModuleSummaryIndexBuilder(
const Module *M,
std::function<BlockFrequencyInfo *(const Function &F)> Ftor)
: Index(llvm::make_unique<ModuleSummaryIndex>()), M(M) {
- // We cannot currently promote or rename anything that is in llvm.used,
- // since any such value may have a use that won't see the new name.
- // Specifically, any uses within inline assembly are not visible to the
- // compiler. Prevent importing of any modules containing these uses by
+ // We cannot currently promote or rename anything used in inline assembly,
+ // which are not visible to the compiler. Detect a possible case by looking
+ // for a llvm.used local value, in conjunction with an inline assembly call
+ // in the module. Prevent importing of any modules containing these uses by
// suppressing generation of the index. This also prevents importing
// into this module, which is also necessary to avoid needing to rename
// in case of a name clash between a local in this module and an imported
@@ -139,10 +140,17 @@ ModuleSummaryIndexBuilder::ModuleSummaryIndexBuilder(
// with a reference could be exported).
SmallPtrSet<GlobalValue *, 8> Used;
collectUsedGlobalVariables(*M, Used, /*CompilerUsed*/ false);
+ bool LocalIsUsed = false;
for (GlobalValue *V : Used) {
- if (V->hasLocalLinkage())
- return;
+ if ((LocalIsUsed |= V->hasLocalLinkage()))
+ break;
}
+ if (LocalIsUsed)
+ for (auto &F : *M)
+ for (auto &I : instructions(F))
+ if (const CallInst *CallI = dyn_cast<CallInst>(&I))
+ if (CallI->isInlineAsm())
+ return;
// Compute summaries for all functions defined in module, and save in the
// index.
OpenPOWER on IntegriCloud