<html 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:"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:"Times New Roman \(Body CS\)";
        panose-1:2 11 6 4 2 2 2 2 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-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.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.gmail-
        {mso-style-name:gmail-;}
span.gmail-im
        {mso-style-name:gmail-im;}
span.EmailStyle20
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
span.EmailStyle22
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;
        font-weight:normal;
        font-style:normal;}
.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>
</head>
<body lang="EN-GB" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Hi Sean,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I have looked at the code size issues and identified the root cause of them.<o:p></o:p></p>
<p class="MsoNormal">The biggest code size increase (from 35512 bytes to 44184 bytes, +24%) is for MultiSource/Benchmarks/MiBench/automotive-susan (<a href="http://www.llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/MiBench/automotive-susan/susan.c?view=markup">http://www.llvm.org/viewvc/llvm-project/test-suite/trunk/MultiSource/Benchmarks/MiBench/automotive-susan/susan.c?view=markup</a>).<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Compiler options: clang  -O3 -DNDEBUG -mcpu=cortex-a57 -fomit-frame-pointer  -c MultiSource/Benchmarks/MiBench/automotive-susan/susan.c<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The problem is that the partial inliner “duplicates” huge functions. I mean “duplicates” because a difference between the original function and the one created by the partial inliner is very small.<o:p></o:p></p>
<p class="MsoNormal">For example:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">define dso_local i32 @susan_edges_small…{<o:p></o:p></p>
<p class="MsoNormal">entry:<o:p></o:p></p>
<p class="MsoNormal">  %0 = bitcast i32* %r to i8*<o:p></o:p></p>
<p class="MsoNormal">  %mul = mul nsw i32 %y_size, %x_size<o:p></o:p></p>
<p class="MsoNormal">  %conv = sext i32 %mul to i64<o:p></o:p></p>
<p class="MsoNormal">  %mul1 = shl nsw i64 %conv, 2<o:p></o:p></p>
<p class="MsoNormal">  tail call void @llvm.memset.p0i8.i64(i8* align 4 %0, i8 0, i64 %mul1, i1 false)<o:p></o:p></p>
<p class="MsoNormal">  %cmp645 = icmp sgt i32 %y_size, 2<o:p></o:p></p>
<p class="MsoNormal">  br i1 %cmp645, label %for.cond3.preheader.lr.ph, label %for.end398<o:p></o:p></p>
<p class="MsoNormal">…<o:p></o:p></p>
<p class="MsoNormal"><<A lot of code: ~500 lines of IR>><o:p></o:p></p>
<p class="MsoNormal">…<o:p></o:p></p>
<p class="MsoNormal">for.end398:                                       ; preds = %for.inc396, %entry, %for.cond84.preheader<o:p></o:p></p>
<p class="MsoNormal">  ret i32 undef<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The partial inliner creates @susan_edges_small.50_for.cond3.preheader.lr.ph where those 500 lines of IR are put.  This results in two huge functions.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">There are four such big functions in susan.c: susan_edges_small, susan_edges, susan_thin and susan_principle.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">IMHO the issue can be solved when functions are put into own sections (this mode is off by default) and then removed by a linker. However this will raise additional requirements how to build and to link an application which cannot be met
 in all cases.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">Evgeny Astigeevich<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Evgeny Astigeevich <Evgeny.Astigeevich@arm.com><br>
<b>Date: </b>Monday, 29 January 2018 at 20:00<br>
<b>To: </b>Sean Fertile <sd.fertile@gmail.com>, Florian Hahn <Florian.Hahn@arm.com><br>
<b>Cc: </b>Graham Yiu <gyiu@ca.ibm.com>, "junbuml@codeaurora.org" <junbuml@codeaurora.org>, "llvm-dev@lists.llvm.org" <llvm-dev@lists.llvm.org>, Tobias Grosser <tobias.grosser@inf.ethz.ch>, nd <nd@arm.com><br>
<b>Subject: </b>Re: [llvm-dev] [RFC] Enable Partial Inliner by default<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><o:p> </o:p></p>
</div>
<p class="MsoNormal" style="margin-left:36.0pt">Hi Sean,<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Thank you for reminding me.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">It looks like it get lost among tons of emails and other tasks.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">I’ll check if the code size issues still exist.<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Thanks,<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt">Evgeny Astigeevich<o:p></o:p></p>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm">
<p class="MsoNormal" style="margin-left:36.0pt"><b><span style="font-size:12.0pt;color:black">From:
</span></b><span style="font-size:12.0pt;color:black">Sean Fertile <sd.fertile@gmail.com><br>
<b>Date: </b>Monday, 29 January 2018 at 19:52<br>
<b>To: </b>Florian Hahn <Florian.Hahn@arm.com><br>
<b>Cc: </b>Evgeny Astigeevich <Evgeny.Astigeevich@arm.com>, Graham Yiu <gyiu@ca.ibm.com>, "junbuml@codeaurora.org" <junbuml@codeaurora.org>, "llvm-dev@lists.llvm.org" <llvm-dev@lists.llvm.org>, Tobias Grosser <tobias.grosser@inf.ethz.ch>, nd <nd@arm.com><br>
<b>Subject: </b>Re: [llvm-dev] [RFC] Enable Partial Inliner by default</span><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"> <o:p></o:p></p>
</div>
<div>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt">
<a name="_MailOriginalBody">Hello All, <o:p></o:p></a></p>
<p style="mso-margin-top-alt:5.0pt;margin-right:0cm;margin-bottom:0cm;margin-left:36.0pt;margin-bottom:.0001pt">
<span style="mso-bookmark:_MailOriginalBody">This conversations seems to have fizzled out and I would like to try to revive it. My intention is to pick up where Graham left off with enabling partial-inlining by default.
<o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="mso-bookmark:_MailOriginalBody"> <o:p></o:p></span></p>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="mso-bookmark:_MailOriginalBody">On Sat, Dec 9, 2017 at 7:47 AM, Florian Hahn via llvm-dev <</span><a href="mailto:llvm-dev@lists.llvm.org" target="_blank"><span style="mso-bookmark:_MailOriginalBody">llvm-dev@lists.llvm.org</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody">>
 wrote:<o:p></o:p></span></p>
<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" style="margin-left:36.0pt"><span style="mso-bookmark:_MailOriginalBody">Hi,<br>
<br>
<span class="gmail-">On 13/11/2017 14:47, Evgeny Astigeevich via llvm-dev wrote:</span><o:p></o:p></span></p>
<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" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span style="mso-bookmark:_MailOriginalBody">Hi Graham,<br>
<br>
I created a bug report with a reproducer for the failures I’ve got: </span><a href="https://bugs.llvm.org/show_bug.cgi?id=35288" target="_blank"><span style="mso-bookmark:_MailOriginalBody">https://bugs.llvm.org/show_bug.cgi?id=35288</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody"><o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span style="mso-bookmark:_MailOriginalBody"><br>
That bug should be fixed by </span><a href="https://reviews.llvm.org/rL320199" target="_blank"><span style="mso-bookmark:_MailOriginalBody">https://reviews.llvm.org/rL320199</span><span style="mso-bookmark:_MailOriginalBody"></span></a><span style="mso-bookmark:_MailOriginalBody"><br>
<br>
Cheers,<br>
Florian<o:p></o:p></span></p>
</blockquote>
</div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="mso-bookmark:_MailOriginalBody"> <o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span style="mso-bookmark:_MailOriginalBody">Thanks for fixing this Florian. Now that this is no longer blocking, are there other concerns over enabling PI by default?<br>
<br>
Evgeny, did you get a chance to look into the code-size regressions on AArch targets? What do you think about moving ahead with this?<br>
<br>
<br>
<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="margin-left:36.0pt"><span style="mso-bookmark:_MailOriginalBody">Thanks<o:p></o:p></span></p>
</div>
<div>
<p class="MsoNormal" style="mso-margin-top-alt:0cm;margin-right:0cm;margin-bottom:12.0pt;margin-left:36.0pt">
<span style="mso-bookmark:_MailOriginalBody">Sean<o:p></o:p></span></p>
</div>
</div>
</div>
</body>
</html>