+
+/// shouldInline - Return true if the inliner should attempt to inline
+/// at the given CallSite.
+bool Inliner::shouldInline(CallSite CS) {
+ int Cost = getInlineCost(CS);
+ float FudgeFactor = getInlineFudgeFactor(CS);
+
+ int CurrentThreshold = InlineThreshold;
+ Function *Fn = CS.getCaller();
+ if (Fn && !Fn->isDeclaration()
+ && Fn->hasFnAttr(Attribute::OptimizeForSize)
+ && InlineThreshold != 50) {
+ CurrentThreshold = 50;
+ }
+
+ if (Cost >= (int)(CurrentThreshold * FudgeFactor)) {
+ DOUT << " NOT Inlining: cost=" << Cost
+ << ", Call: " << *CS.getInstruction();
+ return false;
+ } else {
+ DOUT << " Inlining: cost=" << Cost
+ << ", Call: " << *CS.getInstruction();
+ return true;
+ }
+}