CS.isNoInline())
return llvm::InlineCost::getNever();
- // Don't inline directly recursive calls, for now. Inlining a directly
- // recursive call is effectively unrolling a loop, so it calls for different
- // heuristics, which aren't implemented yet. Until then, err on the
- // conservative side.
- if (Callee == Caller)
- return llvm::InlineCost::getNever();
-
// InlineCost - This value measures how good of an inline candidate this call
// site is to inline. A lower inline cost make is more likely for the call to
// be inlined. This value may go negative.
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;
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;