<div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Tue, Apr 3, 2018 at 12:47 PM via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">All,<br>
A recent commit, D43040/r324557, changed the behavior of the gold plugin<br>
when compiling with LTO.  The change now causes the codegen optimization<br>
level to default to CodeGenOpt::Default (i.e., -O2) rather than use the<br>
LTO optimization level.  The argument was made that the LTO optimization<br>
level should control the amount of cross-module optimizations done by<br>
LTO, but it should not control the codegen optimization level; that<br>
should be based off of the optimization level used during the initial<br>
compilation phase (i.e., bitcode generation).<br></blockquote><div><br>At least as I recall the discussion around optnone/optsize in the pass was that these were in some way special semantically distinct properties (optnone being "good for debugging" (or good for debugging compilers - what's the baseline behavior before optimizations are applied), optsize being "make this fit into something it wouldn't otherwise fit into") but that the gradiations of -ON didn't fit into this kind of model & wouldn't ever be implemented as function attributes.<br><br>CC'd Chandler & Eric who I think had opinions/were involved in those previous discussions.<br> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Assuming the argument is reasonable (it make sense to me), I was hoping<br>
to solicit feedback on how to proceed.  The suggestion in D43040/r324557<br>
was to add function attributes to represent the compile-time<br>
optimization level (which also seems reasonable to me).<br>
<br>
As a first step, I've put together two patches: 1) an llvm patch that<br>
adds the function attributes to the LLVM IR and 2) a clang patch that<br>
attaches these attributes to each function based on the codegen<br>
optimization level.  I then use the function level attributes to<br>
"reconstruct" to codegen optimization level used with LTO.<br>
<br>
Please understand this is very much a WIP and just a very small step<br>
towards a final solution.<br>
<br>
Here are the patches for reference:<br>
Clang: D45226<br>
LLVM: D45225<br>
<br>
Regards,<br>
  Chad<br>
<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div></div>