<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey David<div class=""><br class=""></div><div class="">Looks like this broke the bot (<a href="http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/23731/console" class="">http://lab.llvm.org:8080/green/job/clang-stage1-cmake-RA-incremental_build/23731/console</a>):</div><div class=""><br class=""></div><div class=""><span title="Compile Error" style="box-sizing: border-box; font-family: monospace; font-size: 13px; white-space: pre-wrap; color: white; background-color: red;" class="">/Users/buildslave/jenkins/sharedspace/incremental@2/llvm/lib/Transforms/IPO/Inliner.cpp:334:42: error: use of undeclared identifier 'TotalSecondaryCost'
</span><span style="color: rgb(51, 51, 51); font-family: monospace; font-size: 13px; white-space: pre-wrap;" class=""> << ", outer Cost = " << TotalSecondaryCost << '\n');</span></div><div class=""><br class=""></div><div class="">Mind taking a look?</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Pete</div><div class=""><div><blockquote type="cite" class=""><div class="">On Apr 29, 2016, at 2:21 PM, Xinliang David Li via llvm-commits <<a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">Author: davidxl<br class="">Date: Fri Apr 29 16:21:44 2016<br class="">New Revision: 268107<br class=""><br class="">URL: <a href="http://llvm.org/viewvc/llvm-project?rev=268107&view=rev" class="">http://llvm.org/viewvc/llvm-project?rev=268107&view=rev</a><br class="">Log:<br class="">[inliner]: Refactor inline deferring logic into its own method /NFC<br class=""><br class="">The implemented heuristic has a large body of code which better sits<br class="">in its own function for better readability. It also allows adding more<br class="">heuristics easier in the future.<br class=""><br class="">Modified:<br class=""> llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h<br class=""> llvm/trunk/lib/Transforms/IPO/Inliner.cpp<br class=""><br class="">Modified: llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h?rev=268107&r1=268106&r2=268107&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h?rev=268107&r1=268106&r2=268107&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h (original)<br class="">+++ llvm/trunk/include/llvm/Transforms/IPO/InlinerPass.h Fri Apr 29 16:21:44 2016<br class="">@@ -69,6 +69,10 @@ private:<br class=""> /// shouldInline - Return true if the inliner should attempt to<br class=""> /// inline at the given CallSite.<br class=""> bool shouldInline(CallSite CS);<br class="">+ /// Return true if inlining of CS can block the caller from being<br class="">+ /// inlined which is proved to be more beneficial. \p IC is the<br class="">+ /// estimated inline cost associated with callsite \p CS.<br class="">+ bool shouldBeDeferred(Function *Caller, CallSite CS, InlineCost IC);<br class=""><br class=""> protected:<br class=""> AssumptionCacheTracker *ACT;<br class=""><br class="">Modified: llvm/trunk/lib/Transforms/IPO/Inliner.cpp<br class="">URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=268107&r1=268106&r2=268107&view=diff" class="">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Inliner.cpp?rev=268107&r1=268106&r2=268107&view=diff</a><br class="">==============================================================================<br class="">--- llvm/trunk/lib/Transforms/IPO/Inliner.cpp (original)<br class="">+++ llvm/trunk/lib/Transforms/IPO/Inliner.cpp Fri Apr 29 16:21:44 2016<br class="">@@ -227,6 +227,75 @@ static void emitAnalysis(CallSite CS, co<br class=""> emitOptimizationRemarkAnalysis(Ctx, DEBUG_TYPE, *Caller, DLoc, Msg);<br class=""> }<br class=""><br class="">+bool Inliner::shouldBeDeferred(Function *Caller, CallSite CS, InlineCost IC) {<br class="">+<br class="">+ // For now we only handle local or inline functions.<br class="">+ if (!Caller->hasLocalLinkage() && !Caller->hasLinkOnceODRLinkage())<br class="">+ return false;<br class="">+ // Try to detect the case where the current inlining candidate caller (call<br class="">+ // it B) is a static or linkonce-ODR function and is an inlining candidate<br class="">+ // elsewhere, and the current candidate callee (call it C) is large enough<br class="">+ // that inlining it into B would make B too big to inline later. In these<br class="">+ // circumstances it may be best not to inline C into B, but to inline B into<br class="">+ // its callers.<br class="">+ //<br class="">+ // This only applies to static and linkonce-ODR functions because those are<br class="">+ // expected to be available for inlining in the translation units where they<br class="">+ // are used. Thus we will always have the opportunity to make local inlining<br class="">+ // decisions. Importantly the linkonce-ODR linkage covers inline functions<br class="">+ // and templates in C++.<br class="">+ //<br class="">+ // FIXME: All of this logic should be sunk into getInlineCost. It relies on<br class="">+ // the internal implementation of the inline cost metrics rather than<br class="">+ // treating them as truly abstract units etc.<br class="">+ int TotalSecondaryCost = 0;<br class="">+ // The candidate cost to be imposed upon the current function.<br class="">+ int CandidateCost = IC.getCost() - (InlineConstants::CallPenalty + 1);<br class="">+ // This bool tracks what happens if we do NOT inline C into B.<br class="">+ bool callerWillBeRemoved = Caller->hasLocalLinkage();<br class="">+ // This bool tracks what happens if we DO inline C into B.<br class="">+ bool inliningPreventsSomeOuterInline = false;<br class="">+ for (User *U : Caller->users()) {<br class="">+ CallSite CS2(U);<br class="">+<br class="">+ // If this isn't a call to Caller (it could be some other sort<br class="">+ // of reference) skip it. Such references will prevent the caller<br class="">+ // from being removed.<br class="">+ if (!CS2 || CS2.getCalledFunction() != Caller) {<br class="">+ callerWillBeRemoved = false;<br class="">+ continue;<br class="">+ }<br class="">+<br class="">+ InlineCost IC2 = getInlineCost(CS2);<br class="">+ ++NumCallerCallersAnalyzed;<br class="">+ if (!IC2) {<br class="">+ callerWillBeRemoved = false;<br class="">+ continue;<br class="">+ }<br class="">+ if (IC2.isAlways())<br class="">+ continue;<br class="">+<br class="">+ // See if inlining or original callsite would erase the cost delta of<br class="">+ // this callsite. We subtract off the penalty for the call instruction,<br class="">+ // which we would be deleting.<br class="">+ if (IC2.getCostDelta() <= CandidateCost) {<br class="">+ inliningPreventsSomeOuterInline = true;<br class="">+ TotalSecondaryCost += IC2.getCost();<br class="">+ }<br class="">+ }<br class="">+ // If all outer calls to Caller would get inlined, the cost for the last<br class="">+ // one is set very low by getInlineCost, in anticipation that Caller will<br class="">+ // be removed entirely. We did not account for this above unless there<br class="">+ // is only one caller of Caller.<br class="">+ if (callerWillBeRemoved && !Caller->use_empty())<br class="">+ TotalSecondaryCost += InlineConstants::LastCallToStaticBonus;<br class="">+<br class="">+ if (inliningPreventsSomeOuterInline && TotalSecondaryCost < IC.getCost())<br class="">+ return true;<br class="">+<br class="">+ return false;<br class="">+}<br class="">+<br class=""> /// Return true if the inliner should attempt to inline at the given CallSite.<br class=""> bool Inliner::shouldInline(CallSite CS) {<br class=""> InlineCost IC = getInlineCost(CS);<br class="">@@ -258,77 +327,16 @@ bool Inliner::shouldInline(CallSite CS)<br class=""> Twine(IC.getCostDelta() + IC.getCost()) + ")");<br class=""> return false;<br class=""> }<br class="">- <br class="">- // Try to detect the case where the current inlining candidate caller (call<br class="">- // it B) is a static or linkonce-ODR function and is an inlining candidate<br class="">- // elsewhere, and the current candidate callee (call it C) is large enough<br class="">- // that inlining it into B would make B too big to inline later. In these<br class="">- // circumstances it may be best not to inline C into B, but to inline B into<br class="">- // its callers.<br class="">- //<br class="">- // This only applies to static and linkonce-ODR functions because those are<br class="">- // expected to be available for inlining in the translation units where they<br class="">- // are used. Thus we will always have the opportunity to make local inlining<br class="">- // decisions. Importantly the linkonce-ODR linkage covers inline functions<br class="">- // and templates in C++.<br class="">- //<br class="">- // FIXME: All of this logic should be sunk into getInlineCost. It relies on<br class="">- // the internal implementation of the inline cost metrics rather than<br class="">- // treating them as truly abstract units etc.<br class="">- if (Caller->hasLocalLinkage() || Caller->hasLinkOnceODRLinkage()) {<br class="">- int TotalSecondaryCost = 0;<br class="">- // The candidate cost to be imposed upon the current function.<br class="">- int CandidateCost = IC.getCost() - (InlineConstants::CallPenalty + 1);<br class="">- // This bool tracks what happens if we do NOT inline C into B.<br class="">- bool callerWillBeRemoved = Caller->hasLocalLinkage();<br class="">- // This bool tracks what happens if we DO inline C into B.<br class="">- bool inliningPreventsSomeOuterInline = false;<br class="">- for (User *U : Caller->users()) {<br class="">- CallSite CS2(U);<br class="">-<br class="">- // If this isn't a call to Caller (it could be some other sort<br class="">- // of reference) skip it. Such references will prevent the caller<br class="">- // from being removed.<br class="">- if (!CS2 || CS2.getCalledFunction() != Caller) {<br class="">- callerWillBeRemoved = false;<br class="">- continue;<br class="">- }<br class="">-<br class="">- InlineCost IC2 = getInlineCost(CS2);<br class="">- ++NumCallerCallersAnalyzed;<br class="">- if (!IC2) {<br class="">- callerWillBeRemoved = false;<br class="">- continue;<br class="">- }<br class="">- if (IC2.isAlways())<br class="">- continue;<br class="">-<br class="">- // See if inlining or original callsite would erase the cost delta of<br class="">- // this callsite. We subtract off the penalty for the call instruction,<br class="">- // which we would be deleting.<br class="">- if (IC2.getCostDelta() <= CandidateCost) {<br class="">- inliningPreventsSomeOuterInline = true;<br class="">- TotalSecondaryCost += IC2.getCost();<br class="">- }<br class="">- }<br class="">- // If all outer calls to Caller would get inlined, the cost for the last<br class="">- // one is set very low by getInlineCost, in anticipation that Caller will<br class="">- // be removed entirely. We did not account for this above unless there<br class="">- // is only one caller of Caller.<br class="">- if (callerWillBeRemoved && !Caller->use_empty())<br class="">- TotalSecondaryCost += InlineConstants::LastCallToStaticBonus;<br class="">-<br class="">- if (inliningPreventsSomeOuterInline && TotalSecondaryCost < IC.getCost()) {<br class="">- DEBUG(dbgs() << " NOT Inlining: " << *CS.getInstruction() <<<br class="">- " Cost = " << IC.getCost() <<<br class="">- ", outer Cost = " << TotalSecondaryCost << '\n');<br class="">- emitAnalysis(<br class="">- CS, Twine("Not inlining. Cost of inlining " +<br class="">- CS.getCalledFunction()->getName() +<br class="">- " increases the cost of inlining " +<br class="">- CS.getCaller()->getName() + " in other contexts"));<br class="">- return false;<br class="">- }<br class="">+<br class="">+ if (shouldBeDeferred(Caller, CS, IC)) {<br class="">+ DEBUG(dbgs() << " NOT Inlining: " << *CS.getInstruction()<br class="">+ << " Cost = " << IC.getCost()<br class="">+ << ", outer Cost = " << TotalSecondaryCost << '\n');<br class="">+ emitAnalysis(CS, Twine("Not inlining. Cost of inlining " +<br class="">+ CS.getCalledFunction()->getName() +<br class="">+ " increases the cost of inlining " +<br class="">+ CS.getCaller()->getName() + " in other contexts"));<br class="">+ return false;<br class=""> }<br class=""><br class=""> DEBUG(dbgs() << " Inlining: cost=" << IC.getCost()<br class=""><br class=""><br class="">_______________________________________________<br class="">llvm-commits mailing list<br class=""><a href="mailto:llvm-commits@lists.llvm.org" class="">llvm-commits@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits<br class=""></div></div></blockquote></div><br class=""></div></body></html>