Adjustments to last patch based on review.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61969 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Utils/InlineCost.cpp b/lib/Transforms/Utils/InlineCost.cpp
index 82e310b..90d72ef 100644
--- a/lib/Transforms/Utils/InlineCost.cpp
+++ b/lib/Transforms/Utils/InlineCost.cpp
@@ -127,7 +127,7 @@
       }
       
       if (const AllocaInst *AI = dyn_cast<AllocaInst>(II)) {
-        if (!isa<ConstantInt>(AI->getArraySize()))
+        if (!AI->isStaticAlloca())
           this->usesDynamicAlloca = true;
       }
 
@@ -229,18 +229,20 @@
   if (CalleeFI.NeverInline)
     return InlineCost::getNever();
 
-  // Get infomation about the caller...
-  FunctionInfo &CallerFI = CachedFunctionInfo[Caller];
+  if (CalleeFI.usesDynamicAlloca) {
+    // Get infomation about the caller...
+    FunctionInfo &CallerFI = CachedFunctionInfo[Caller];
 
-  // If we haven't calculated this information yet, do so now.
-  if (CallerFI.NumBlocks == 0)
-    CallerFI.analyzeFunction(Caller);
+    // If we haven't calculated this information yet, do so now.
+    if (CallerFI.NumBlocks == 0)
+      CallerFI.analyzeFunction(Caller);
 
-  // Don't inline a callee with dynamic alloca into a caller without them.
-  // Functions containing dynamic alloca's are inefficient in various ways;
-  // don't create more inefficiency.
-  if (CalleeFI.usesDynamicAlloca && !CallerFI.usesDynamicAlloca)
-    return InlineCost::getNever();
+    // Don't inline a callee with dynamic alloca into a caller without them.
+    // Functions containing dynamic alloca's are inefficient in various ways;
+    // don't create more inefficiency.
+    if (!CallerFI.usesDynamicAlloca)
+      return InlineCost::getNever();
+  }
 
   // FIXME: It would be nice to kill off CalleeFI.NeverInline. Then we
   // could move this up and avoid computing the FunctionInfo for