diff options
| author | Chris Lattner <sabre@nondot.org> | 2010-04-17 17:57:56 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2010-04-17 17:57:56 +0000 |
| commit | 67e70971ccc258d3a5dac00a8e93af82b41ecb2d (patch) | |
| tree | c1ffe005554f5db0471e556cd90eee5560169d00 /llvm/lib/Analysis | |
| parent | cea19a475bb1b147db0fba55582812105e22da69 (diff) | |
| download | bcm5719-llvm-67e70971ccc258d3a5dac00a8e93af82b41ecb2d.tar.gz bcm5719-llvm-67e70971ccc258d3a5dac00a8e93af82b41ecb2d.zip | |
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.
llvm-svn: 101658
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/InlineCost.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index acc3f202f27..50400d3085d 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/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; |

