Add InlineCost class for represent the estimated cost of inlining a
[oota-llvm.git] / lib / Transforms / Utils / BasicInliner.cpp
index ba1fb3d9c4ea00ce6ef5263e34bfc33f97d1ae90..73e8bd84676b6301e45e9cd9f906610f1359cf28 100644 (file)
@@ -107,16 +107,27 @@ void BasicInlinerImpl::inlineFunctions() {
           --index;
           continue;
         }
-        int InlineCost = CA.getInlineCost(CS, NeverInline);
-        if (InlineCost >= (int) BasicInlineThreshold) {
-          DOUT << "  NOT Inlining: cost = " << InlineCost
-               << ", call: " <<  *CS.getInstruction();
+        InlineCost IC = CA.getInlineCost(CS, NeverInline);
+        if (IC.isAlways()) {        
+          DOUT << "  Inlining: cost=always"
+               <<", call: " << *CS.getInstruction();
+        } else if (IC.isNever()) {
+          DOUT << "  NOT Inlining: cost=never"
+               <<", call: " << *CS.getInstruction();
           continue;
+        } else {
+          int Cost = IC.getValue();
+          
+          if (Cost >= BasicInlineThreshold) {
+            DOUT << "  NOT Inlining: cost = " << Cost
+                 << ", call: " <<  *CS.getInstruction();
+            continue;
+          } else {
+            DOUT << "  Inlining: cost = " << Cost
+                 << ", call: " <<  *CS.getInstruction();
+          }
         }
         
-        DOUT << "  Inlining: cost=" << InlineCost
-             <<", call: " << *CS.getInstruction();
-        
         // Inline
         if (InlineFunction(CS, NULL, TD)) {
           if (Callee->use_empty() && Callee->hasInternalLinkage())