aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Analysis/InlineCost.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-04-17 17:57:56 +0000
committerChris Lattner <sabre@nondot.org>2010-04-17 17:57:56 +0000
commitf84755b8360d13b1d19df821d9e8692aac7e9b87 (patch)
treed4e2d31b2b3f29f59c9e25e2414422348d62b8fa /lib/Analysis/InlineCost.cpp
parent44b04a5f4ac8a2b9b3208a937f2ba36bcf7aa40f (diff)
downloadexternal_llvm-f84755b8360d13b1d19df821d9e8692aac7e9b87.zip
external_llvm-f84755b8360d13b1d19df821d9e8692aac7e9b87.tar.gz
external_llvm-f84755b8360d13b1d19df821d9e8692aac7e9b87.tar.bz2
fix PR6858: a dangling pointer use bug which was caused
by switching CachedFunctionInfo from a std::map to a ValueMap (which is implemented in terms of a DenseMap). DenseMap has different iterator invalidation semantics than std::map. This should hopefully fix the dragonegg builder. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@101658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/InlineCost.cpp')
-rw-r--r--lib/Analysis/InlineCost.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/Analysis/InlineCost.cpp b/lib/Analysis/InlineCost.cpp
index acc3f20..50400d3 100644
--- a/lib/Analysis/InlineCost.cpp
+++ b/lib/Analysis/InlineCost.cpp
@@ -319,8 +319,13 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
FunctionInfo &CallerFI = CachedFunctionInfo[Caller];
// If we haven't calculated this information yet, do so now.
- if (CallerFI.Metrics.NumBlocks == 0)
+ if (CallerFI.Metrics.NumBlocks == 0) {
CallerFI.analyzeFunction(Caller);
+
+ // Recompute the CalleeFI pointer, getting Caller could have invalidated
+ // it.
+ CalleeFI = &CachedFunctionInfo[Callee];
+ }
// Don't inline a callee with dynamic alloca into a caller without them.
// Functions containing dynamic alloca's are inefficient in various ways;
@@ -426,6 +431,8 @@ InlineCostAnalyzer::growCachedCostInfo(Function *Caller, Function *Callee) {
return;
}
+ // Since CalleeMetrics were already calculated, we know that the CallerMetrics
+ // reference isn't invalidated: both were in the DenseMap.
CallerMetrics.NeverInline |= CalleeMetrics.NeverInline;
CallerMetrics.usesDynamicAlloca |= CalleeMetrics.usesDynamicAlloca;