summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Analysis
diff options
context:
space:
mode:
authorBjorn Steinbrink <bsteinbr@gmail.com>2015-02-12 21:04:22 +0000
committerBjorn Steinbrink <bsteinbr@gmail.com>2015-02-12 21:04:22 +0000
commit6f972a13f6e55668f811e71690ad33f728caf61e (patch)
tree2851859da366d7645fa4c29cb131a27ed6a5a84e /llvm/lib/Analysis
parente8cb17f2824537e30bc536ba354f16d622d6e60b (diff)
downloadbcm5719-llvm-6f972a13f6e55668f811e71690ad33f728caf61e.tar.gz
bcm5719-llvm-6f972a13f6e55668f811e71690ad33f728caf61e.zip
Fix a crash in the assumption cache when inlining indirect function calls
Summary: Instances of the AssumptionCache are per function, so we can't re-use the same AssumptionCache instance when recursing in the CallAnalyzer to analyze a different function. Instead we have to pass the AssumptionCacheTracker to the CallAnalyzer so it can get the right AssumptionCache on demand. Reviewers: hfinkel Subscribers: llvm-commits, hans Differential Revision: http://reviews.llvm.org/D7533 llvm-svn: 228957
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r--llvm/lib/Analysis/IPA/InlineCost.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/IPA/InlineCost.cpp b/llvm/lib/Analysis/IPA/InlineCost.cpp
index 64f78f408fd..775a9fb1f61 100644
--- a/llvm/lib/Analysis/IPA/InlineCost.cpp
+++ b/llvm/lib/Analysis/IPA/InlineCost.cpp
@@ -52,7 +52,7 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
const TargetTransformInfo &TTI;
/// The cache of @llvm.assume intrinsics.
- AssumptionCache &AC;
+ AssumptionCacheTracker *ACT;
// The called function.
Function &F;
@@ -146,8 +146,8 @@ class CallAnalyzer : public InstVisitor<CallAnalyzer, bool> {
public:
CallAnalyzer(const DataLayout *DL, const TargetTransformInfo &TTI,
- AssumptionCache &AC, Function &Callee, int Threshold)
- : DL(DL), TTI(TTI), AC(AC), F(Callee), Threshold(Threshold), Cost(0),
+ AssumptionCacheTracker *ACT, Function &Callee, int Threshold)
+ : DL(DL), TTI(TTI), ACT(ACT), F(Callee), Threshold(Threshold), Cost(0),
IsCallerRecursive(false), IsRecursiveCall(false),
ExposesReturnsTwice(false), HasDynamicAlloca(false),
ContainsNoDuplicateCall(false), HasReturn(false), HasIndirectBr(false),
@@ -789,7 +789,7 @@ bool CallAnalyzer::visitCallSite(CallSite CS) {
// during devirtualization and so we want to give it a hefty bonus for
// inlining, but cap that bonus in the event that inlining wouldn't pan
// out. Pretend to inline the function, with a custom threshold.
- CallAnalyzer CA(DL, TTI, AC, *F, InlineConstants::IndirectCallThreshold);
+ CallAnalyzer CA(DL, TTI, ACT, *F, InlineConstants::IndirectCallThreshold);
if (CA.analyzeCall(CS)) {
// We were able to inline the indirect call! Subtract the cost from the
// bonus we want to apply, but don't go below zero.
@@ -1135,7 +1135,7 @@ bool CallAnalyzer::analyzeCall(CallSite CS) {
// the ephemeral values multiple times (and they're completely determined by
// the callee, so this is purely duplicate work).
SmallPtrSet<const Value *, 32> EphValues;
- CodeMetrics::collectEphemeralValues(&F, &AC, EphValues);
+ CodeMetrics::collectEphemeralValues(&F, &ACT->getAssumptionCache(F), EphValues);
// The worklist of live basic blocks in the callee *after* inlining. We avoid
// adding basic blocks of the callee which can be proven to be dead for this
@@ -1335,7 +1335,7 @@ InlineCost InlineCostAnalysis::getInlineCost(CallSite CS, Function *Callee,
<< "...\n");
CallAnalyzer CA(Callee->getDataLayout(), TTIWP->getTTI(*Callee),
- ACT->getAssumptionCache(*Callee), *Callee, Threshold);
+ ACT, *Callee, Threshold);
bool ShouldInline = CA.analyzeCall(CS);
DEBUG(CA.dump());
OpenPOWER on IntegriCloud