Set isSigned to true when creating an all-ones integer constant, even
[oota-llvm.git] / lib / Analysis / InlineCost.cpp
index acc3f202f2795720c9df60f70c477ec56261f3c5..cb9e5526fc4062eb1986856e8bad19e1e5547382 100644 (file)
@@ -263,13 +263,6 @@ InlineCost InlineCostAnalyzer::getInlineCost(CallSite CS,
       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.
@@ -319,8 +312,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 +424,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;