<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hi Martin,</p>
    I think this is another example of why we might consider having such
    function level attributes.. yes.<br>
    <br>
     Chad<br>
    <br>
    <br>
    <div class="moz-cite-prefix">On 4/4/2018 11:42 AM, Martin J.
      O'Riordan via llvm-dev wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:006501d3cc2b$7e2a2e70$7a7e8b50$@theheart.ie">
      <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:"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:"Book Antiqua";
        panose-1:2 4 6 2 5 3 5 3 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
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;}
span.EmailStyle17
        {mso-style-type:personal;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Book Antiqua",serif;
        color:#943634;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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]-->
      <div class="WordSection1">
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">Sorry,
            my reply “to all” left out LLVM-Dev<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <div>
          <div style="border:none;border-top:solid #E1E1E1
            1.0pt;padding:3.0pt 0cm 0cm 0cm">
            <p class="MsoNormal"><b><span
                  style="font-size:11.0pt;font-family:"Calibri",sans-serif"
                  lang="EN-US">From:</span></b><span
                style="font-size:11.0pt;font-family:"Calibri",sans-serif"
                lang="EN-US"> Martin J. O'Riordan
                [<a class="moz-txt-link-freetext" 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 class="moz-txt-link-rfc2396E" href="mailto:dblaikie@gmail.com"><dblaikie@gmail.com></a>;
                '<a class="moz-txt-link-abbreviated" href="mailto:mcrosier@codeaurora.org">mcrosier@codeaurora.org</a>'
                <a class="moz-txt-link-rfc2396E" href="mailto:mcrosier@codeaurora.org"><mcrosier@codeaurora.org></a>; 'Chandler Carruth'
                <a class="moz-txt-link-rfc2396E" href="mailto:chandlerc@gmail.com"><chandlerc@gmail.com></a>; 'Eric Christopher'
                <a class="moz-txt-link-rfc2396E" 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<o:p></o:p></span></p>
          </div>
        </div>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">Would
            implementing GCC’s ‘</span><span
            style="font-family:"Courier
            New";color:black;mso-fareast-language:EN-US">__attribute__((optimize(...)))</span><span
            style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">’
            help?<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">I
            can’t find any good documentation for this attribute, but it
            seems that GCC supports this in two forms:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><span
            style="font-family:"Courier
            New";color:black;mso-fareast-language:EN-US">__attribute__((optimize(2)))<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">meaning
            optimise equivalent to ‘</span><span
            style="font-family:"Courier
            New";color:black;mso-fareast-language:EN-US">-O2</span><span
            style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">’,
            and:<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal" style="margin-left:36.0pt"><span
            style="font-family:"Courier
            New";color:black;mso-fareast-language:EN-US">__attribute_((optimize("fblah",
            "O1")))<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">meaning
            optimise with the provided discrete options.<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US">           
            MartinO<o:p></o:p></span></p>
        <p class="MsoNormal"><span style="font-family:"Book
            Antiqua",serif;color:#943634;mso-fareast-language:EN-US"><o:p> </o:p></span></p>
        <p class="MsoNormal"><b><span
              style="font-size:11.0pt;font-family:"Calibri",sans-serif"
              lang="EN-US">From:</span></b><span
            style="font-size:11.0pt;font-family:"Calibri",sans-serif"
            lang="EN-US"> llvm-dev [<a
              href="mailto:llvm-dev-bounces@lists.llvm.org"
              moz-do-not-send="true">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"
              moz-do-not-send="true">mcrosier@codeaurora.org</a>;
            Chandler Carruth <<a href="mailto:chandlerc@gmail.com"
              moz-do-not-send="true">chandlerc@gmail.com</a>>; Eric
            Christopher <<a href="mailto:echristo@gmail.com"
              moz-do-not-send="true">echristo@gmail.com</a>><br>
            <b>Cc:</b> <a href="mailto:llvm-dev@lists.llvm.org"
              moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
            <b>Subject:</b> Re: [llvm-dev] [RFC] Adding function
            attributes to represent codegen optimization level<o:p></o:p></span></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"
                  moz-do-not-send="true">llvm-dev@lists.llvm.org</a>>
                wrote:<o:p></o:p></p>
            </div>
            <blockquote style="border:none;border-left:solid #CCCCCC
              1.0pt;padding:0cm 0cm 0cm
6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;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:0cm 0cm 0cm
6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0cm;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"
                  moz-do-not-send="true">llvm-dev@lists.llvm.org</a><br>
                <a
                  href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev"
                  target="_blank" moz-do-not-send="true">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><o:p></o:p></p>
            </blockquote>
          </div>
        </div>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>