<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:SimSun;
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"\@SimSun";
        panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
        {font-family:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
span.EmailStyle18
        {mso-style-type:personal;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.EmailStyle19
        {mso-style-type:personal;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Yes, this is very useful RFC for being able to control optimization level at function level. We may also want to provide fp-model=<fast|precised …> control
 at function level via attributes as well. However, the “merge” actions of all these attributes need to be carefully defined and designed for LTO and IPO optimizations.   <o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">Xinmin
</span><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p></o:p></span></p>
<p class="MsoNormal"><a name="_MailEndCompose"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:#1F497D"><o:p> </o:p></span></a></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><a name="_____replyseparator"></a><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif;color:windowtext"> llvm-dev [mailto:llvm-dev-bounces@lists.llvm.org]
<b>On Behalf Of </b>Chad Rosier via llvm-dev<br>
<b>Sent:</b> Wednesday, April 4, 2018 8:54 AM<br>
<b>To:</b> Martin J. O'Riordan <MartinO@theheart.ie>; 'LLVM Developers' <llvm-dev@lists.llvm.org><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] Adding function attributes to represent codegen optimization level<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p>Hi Martin,<o:p></o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">I think this is another example of why we might consider having such function level attributes.. yes.<br>
<br>
 Chad<br>
<br>
<o:p></o:p></p>
<div>
<p class="MsoNormal">On 4/4/2018 11:42 AM, Martin J. O'Riordan via llvm-dev wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Sorry, my reply “to all” left out LLVM-Dev<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Martin J. O'Riordan [<a href="mailto:MartinO@theheart.ie">mailto:MartinO@theheart.ie</a>]
<br>
<b>Sent:</b> 04 April 2018 16:41<br>
<b>To:</b> 'David Blaikie' <a href="mailto:dblaikie@gmail.com"><dblaikie@gmail.com></a>; '<a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>'
<a href="mailto:mcrosier@codeaurora.org"><mcrosier@codeaurora.org></a>; 'Chandler Carruth'
<a href="mailto:chandlerc@gmail.com"><chandlerc@gmail.com></a>; 'Eric Christopher'
<a href="mailto:echristo@gmail.com"><echristo@gmail.com></a><br>
<b>Subject:</b> RE: [llvm-dev] [RFC] Adding function attributes to represent codegen optimization level</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Would implementing GCC’s ‘__attribute__((optimize(...)))’ help?<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">I can’t find any good documentation for this attribute, but it seems that GCC supports this in two forms:<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">__attribute__((optimize(2)))<o:p></o:p></p>
<p class="MsoNormal">meaning optimise equivalent to ‘-O2’, and:<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:.5in">__attribute_((optimize("fblah", "O1")))<o:p></o:p></p>
<p class="MsoNormal">meaning optimise with the provided discrete options.<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">            MartinO<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> llvm-dev [<a href="mailto:llvm-dev-bounces@lists.llvm.org">mailto:llvm-dev-bounces@lists.llvm.org</a>]
<b>On Behalf Of </b>David Blaikie via llvm-dev<br>
<b>Sent:</b> 04 April 2018 15:41<br>
<b>To:</b> <a href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>; Chandler Carruth <<a href="mailto:chandlerc@gmail.com">chandlerc@gmail.com</a>>; Eric Christopher <<a href="mailto:echristo@gmail.com">echristo@gmail.com</a>><br>
<b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> Re: [llvm-dev] [RFC] Adding function attributes to represent codegen optimization level</span><o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<div>
<p class="MsoNormal" style="margin-bottom:12.0pt"> <o:p></o:p></p>
<div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal">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).<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><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>
 <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
<p class="MsoNormal"><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" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
</blockquote>
</div>
</div>
<p class="MsoNormal"><br>
<br>
<br>
<o:p></o:p></p>
<pre>_______________________________________________<o:p></o:p></pre>
<pre>LLVM Developers mailing list<o:p></o:p></pre>
<pre><a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><o:p></o:p></pre>
<pre><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>