<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 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:Tahoma;
panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
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;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
{mso-style-priority:34;
margin-top:0in;
margin-right:0in;
margin-bottom:0in;
margin-left:.5in;
margin-bottom:.0001pt;
font-size:12.0pt;
font-family:"Times New Roman","serif";}
span.EmailStyle17
{mso-style-type:personal-reply;
font-family:"Calibri","sans-serif";
color:#1F497D;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";}
@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 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:#1F497D">If we're not storing actual optimization levels (which is Chandler's expressed preference, in the review), and just looking at optnone/not-optnone, then all
those questions have straightforward answers (2 & 3 are already things the existing optnone attribute has to deal with).<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">1) every function would be marked as optnone or not, so there is no concept of a "module" optimization level.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">2) inlining is already well-defined for optnone v. not-optnone:<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">2a) calls made by an optnone function are never inlined except for calls to always_inline functions<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">2b) optnone functions are always noinline, therefore calls to an optnone function are never inlined<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">3) optnone functions use FastISel (assuming that's what you meant by "code generator")<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">--paulr<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 #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> Eric Christopher [mailto:echristo@gmail.com]
<br>
<b>Sent:</b> Tuesday, January 17, 2017 5:39 PM<br>
<b>To:</b> Robinson, Paul; llvm-dev@lists.llvm.org; Mehdi Amini<br>
<b>Subject:</b> Re: [llvm-dev] Redefining optnone to help LTO<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Honestly instead of optnone I'd prefer to do something else around storing optimization levels, but I think the connotations of that in LTO is going to be painful:<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">1) What does it mean to merge two modules of different optimization levels?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">2) What does it mean to inline two functions of different optimization levels?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">3) What code generator should be used?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Etc.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Honestly I think this is a lot of stuff we don't have any good ideas for and that the current LTO scope doesn't really have. If there's really a need for it though...<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">(Also, if we don't want to store the actual optimization levels then replace "different optimization levels" above with "optnone and not-optnone" :)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-eric<o:p></o:p></p>
</div>
<p class="MsoNormal" style="margin-bottom:12.0pt"><o:p> </o:p></p>
<div>
<p class="MsoNormal">On Wed, Jan 11, 2017 at 8:34 AM Robinson, Paul via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal">In D28404, Mehdi wanted to use the 'optnone' attribute as a way to record<br>
"I was compiled with -O0" in the IR, because it seems like a good idea to<br>
remember that fact in an LTO compilation and there is no way to remember<br>
that fact currently. A couple of people felt it might be better to have<br>
this idea discussed on the dev list, where it might get better exposure,<br>
so I'm volunteering to get that discussion started.<br>
<br>
While 'optnone' does cause lots of optimizations to bypass a function,<br>
exactly matching -O0 was not the motivation and never a hard requirement.<br>
The implementation makes a distinct effort to get close to the behavior<br>
of -O0, but it's not an exact match and for the intended purpose (allowing<br>
a given function to be un-optimized to help debugging) it worked fine.<br>
<br>
Using 'optnone' to convey -O0 to LTO is something of a redefinition, or<br>
at least a re-purposing, of the attribute. To get there from here, I<br>
think we would need a couple of things to happen, separately from the<br>
minor grunt work of adding 'optnone' to function IR at -O0.<br>
<br>
1) Update the LangRef definition of 'optnone' to reflect this intent.<br>
The current definition doesn't provide a motivation, and the description<br>
is (deliberately) a bit vague. If we want 'optnone' to intentionally<br>
match -O0, that should be tightened up.<br>
<br>
2) Make a concerted effort to teach 'optnone' to targets. Currently<br>
I know the X86 target is aware of it, but I'm not so sure about others.<br>
<br>
3) Take another look at what 'optnone' currently does *not* turn off,<br>
and see if there is something we can do about that. In some cases this<br>
will not be practical, and we may just have to live with that.<br>
<br>
(Okay, we need 3 things to happen.)<br>
<br>
I won't say this is blocking Mehdi's work, but it would remove a<br>
point of contention and allow the review to proceed more smoothly.<br>
--paulr<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>
</div>
</body>
</html>