<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Mar 12, 2014 at 9:41 AM, Eric Christopher <span dir="ltr"><<a href="mailto:echristo@gmail.com" target="_blank">echristo@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">You seem to have dropped the comments here...<br></blockquote><div><br></div><div>Resurrected in r203675</div><div><br>
</div><div>Eli</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<span class="HOEnZb"><font color="#888888"><br>
-eric<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On Wed, Mar 12, 2014 at 9:12 AM, Eli Bendersky <<a href="mailto:eliben@google.com">eliben@google.com</a>> wrote:<br>
> Author: eliben<br>
> Date: Wed Mar 12 11:12:36 2014<br>
> New Revision: 203669<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=203669&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=203669&view=rev</a><br>
> Log:<br>
> Move duplicated code into a helper function (exposed through overload).<br>
><br>
> There's a bit of duplicated "magic" code in opt.cpp and Clang's CodeGen that<br>
> computes the inliner threshold from opt level and size opt level.<br>
><br>
> This patch moves the code to a function that lives alongside the inliner itself,<br>
> providing a convenient overload to the inliner creation.<br>
><br>
> A separate patch can be committed to Clang to use this once it's committed to<br>
> LLVM. Standalone tools that use the inlining pass can also avoid duplicating<br>
> this code and fearing it will go out of sync.<br>
><br>
> Note: this patch also restructures the conditinal logic of the computation to<br>
> be cleaner.<br>
><br>
><br>
> Modified:<br>
> llvm/trunk/include/llvm/Transforms/IPO.h<br>
> llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp<br>
> llvm/trunk/tools/opt/opt.cpp<br>
><br>
> Modified: llvm/trunk/include/llvm/Transforms/IPO.h<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=203669&r1=203668&r2=203669&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Transforms/IPO.h?rev=203669&r1=203668&r2=203669&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/include/llvm/Transforms/IPO.h (original)<br>
> +++ llvm/trunk/include/llvm/Transforms/IPO.h Wed Mar 12 11:12:36 2014<br>
> @@ -34,7 +34,7 @@ ModulePass *createStripSymbolsPass(bool<br>
><br>
> //===----------------------------------------------------------------------===//<br>
> //<br>
> -// These functions strips symbols from functions and modules.<br>
> +// These functions strips symbols from functions and modules.<br>
> // Only debugging information is not stripped.<br>
> //<br>
> ModulePass *createStripNonDebugSymbolsPass();<br>
> @@ -78,20 +78,24 @@ ModulePass *createGlobalDCEPass();<br>
> /// the specified global values. Otherwise, it deletes as much of the module as<br>
> /// possible, except for the global values specified.<br>
> ///<br>
> -ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool<br>
> +ModulePass *createGVExtractionPass(std::vector<GlobalValue*>& GVs, bool<br>
> deleteFn = false);<br>
><br>
> //===----------------------------------------------------------------------===//<br>
> /// createFunctionInliningPass - Return a new pass object that uses a heuristic<br>
> /// to inline direct function calls to small functions.<br>
> ///<br>
> +/// The Threshold can be passed directly, or asked to be computed from the<br>
> +/// given optimization and size optimization arguments.<br>
> +///<br>
> /// The -inline-threshold command line option takes precedence over the<br>
> /// threshold given here.<br>
> Pass *createFunctionInliningPass();<br>
> Pass *createFunctionInliningPass(int Threshold);<br>
> +Pass *createFunctionInliningPass(unsigned OptLevel, unsigned SizeOptLevel);<br>
><br>
> //===----------------------------------------------------------------------===//<br>
> -/// createAlwaysInlinerPass - Return a new pass object that inlines only<br>
> +/// createAlwaysInlinerPass - Return a new pass object that inlines only<br>
> /// functions that are marked as "always_inline".<br>
> Pass *createAlwaysInlinerPass();<br>
> Pass *createAlwaysInlinerPass(bool InsertLifetime);<br>
> @@ -192,7 +196,7 @@ ModulePass *createMergeFunctionsPass();<br>
> /// createPartialInliningPass - This pass inlines parts of functions.<br>
> ///<br>
> ModulePass *createPartialInliningPass();<br>
> -<br>
> +<br>
> //===----------------------------------------------------------------------===//<br>
> // createMetaRenamerPass - Rename everything with metasyntatic names.<br>
> //<br>
><br>
> Modified: llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=203669&r1=203668&r2=203669&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp?rev=203669&r1=203668&r2=203669&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp (original)<br>
> +++ llvm/trunk/lib/Transforms/IPO/InlineSimple.cpp Wed Mar 12 11:12:36 2014<br>
> @@ -56,6 +56,17 @@ public:<br>
> void getAnalysisUsage(AnalysisUsage &AU) const override;<br>
> };<br>
><br>
> +static int computeThresholdFromOptLevels(unsigned OptLevel,<br>
> + unsigned SizeOptLevel) {<br>
> + if (OptLevel > 2)<br>
> + return 275;<br>
> + if (SizeOptLevel == 1)<br>
> + return 75;<br>
> + if (SizeOptLevel == 2)<br>
> + return 25;<br>
> + return 225;<br>
> +}<br>
> +<br>
> } // end anonymous namespace<br>
><br>
> char SimpleInliner::ID = 0;<br>
> @@ -72,6 +83,12 @@ Pass *llvm::createFunctionInliningPass(i<br>
> return new SimpleInliner(Threshold);<br>
> }<br>
><br>
> +Pass *llvm::createFunctionInliningPass(unsigned OptLevel,<br>
> + unsigned SizeOptLevel) {<br>
> + return new SimpleInliner(<br>
> + computeThresholdFromOptLevels(OptLevel, SizeOptLevel));<br>
> +}<br>
> +<br>
> bool SimpleInliner::runOnSCC(CallGraphSCC &SCC) {<br>
> ICA = &getAnalysis<InlineCostAnalysis>();<br>
> return Inliner::runOnSCC(SCC);<br>
><br>
> Modified: llvm/trunk/tools/opt/opt.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=203669&r1=203668&r2=203669&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/opt/opt.cpp?rev=203669&r1=203668&r2=203669&view=diff</a><br>
> ==============================================================================<br>
> --- llvm/trunk/tools/opt/opt.cpp (original)<br>
> +++ llvm/trunk/tools/opt/opt.cpp Wed Mar 12 11:12:36 2014<br>
> @@ -210,14 +210,7 @@ static void AddOptimizationPasses(PassMa<br>
> if (DisableInline) {<br>
> // No inlining pass<br>
> } else if (OptLevel > 1) {<br>
> - unsigned Threshold = 225;<br>
> - if (SizeLevel == 1) // -Os<br>
> - Threshold = 75;<br>
> - else if (SizeLevel == 2) // -Oz<br>
> - Threshold = 25;<br>
> - if (OptLevel > 2)<br>
> - Threshold = 275;<br>
> - Builder.Inliner = createFunctionInliningPass(Threshold);<br>
> + Builder.Inliner = createFunctionInliningPass(OptLevel, SizeLevel);<br>
> } else {<br>
> Builder.Inliner = createAlwaysInlinerPass();<br>
> }<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</div></div></blockquote></div><br></div></div>