[llvm-commits] [llvm] r101658 - /llvm/trunk/lib/Analysis/InlineCost.cpp
Chris Lattner
sabre at nondot.org
Sat Apr 17 10:57:56 PDT 2010
Author: lattner
Date: Sat Apr 17 12:57:56 2010
New Revision: 101658
URL: http://llvm.org/viewvc/llvm-project?rev=101658&view=rev
Log:
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.
Modified:
llvm/trunk/lib/Analysis/InlineCost.cpp
Modified: llvm/trunk/lib/Analysis/InlineCost.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/InlineCost.cpp?rev=101658&r1=101657&r2=101658&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/InlineCost.cpp (original)
+++ llvm/trunk/lib/Analysis/InlineCost.cpp Sat Apr 17 12:57:56 2010
@@ -319,8 +319,13 @@
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 @@
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;
More information about the llvm-commits
mailing list