<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Vedant,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
thanks for your answer and sorry for the late response. </div>
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(32, 31, 30); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif; font-size: 15px; background-color: rgb(255, 255, 255); display: inline !important">It seems
 like D68076 might not address the underlying issue here (e.g. it probably doesn't improve the situation for projects using `-g -fno-unwind-tables`?).</span></div>
</blockquote>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Yes, D68075 is a somewhat conservative patch that aligns the behaviour on AArch64 (for GNU targets) that leads to consistent generated assembly. As you said it does not help if unwind tables are explicitly disabled (`-fno-unwind-tables`). It is a conservative
 patch since it decreases scheduling potential (due to smaller scheduling regions) for the non-debug case but fixes the bug of generating inconsistent assembly. </div>
<blockquote style="border-left: 3px solid rgb(200, 200, 200); border-top-color: rgb(200, 200, 200); border-right-color: rgb(200, 200, 200); border-bottom-color: rgb(200, 200, 200); padding-left: 1ex; margin-left: 0.8ex; color: rgb(102, 102, 102);">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span style="color: rgb(32, 31, 30); font-family: "Segoe UI", "Segoe UI Web (West European)", "Segoe UI", -apple-system, system-ui, Roboto, "Helvetica Neue", sans-serif; font-size: 15px; background-color: rgb(255, 255, 255); display: inline !important">Would
 you mind elaborating a bit on your proposals to delay/change CFI instruction insertion? In particular, it'd help to hear a bit about how CFI instructions are inserted today (is some of it done by CFIInstrInserter, and the rest by target-specific frame lowering
 code?).</span><br>
</div>
</blockquote>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
CFI instructions are inserted during target specific frame lowering, the CFIInstrInserter is only run on X86 targets and seems to verify the correctness of CFI instructions after the got inserted during X86 frame lowering.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Regarding the 3 possible roadmaps to solve the issue (see my first email) I currently think 3 (changing instruction scheduling such that CFI instructions are scheduled together with stack altering instructions) is the most promising one because it wouldn't
 require targets specific changes. Since e.g. X86 or if I remember correctly also AArch64 on Darwin targets insert CFI instructions in both, debug and non-debug mode, solution 3 would increase scheduling potential for these targets.</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
To summarize: D68075 would align non-debug mode with debug mode and therefore potentially *decrease* scheduling potential. Solution 3 would align debug mode with non-debug mode (in terms of instruction scheduling) and therefore *increase* scheduling potential. </div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
    David</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> vsk@apple.com <vsk@apple.com> on behalf of Vedant Kumar <vedant_kumar@apple.com><br>
<b>Sent:</b> 30 September 2019 20:50<br>
<b>To:</b> David Tellenbach <David.Tellenbach@arm.com><br>
<b>Cc:</b> paul.robinson@sony.com <paul.robinson@sony.com>; llvm-dev@lists.llvm.org <llvm-dev@lists.llvm.org>; nd <nd@arm.com>; Tim Northover <tnorthover@apple.com>; Ahmed Bougacha <abougacha@apple.com><br>
<b>Subject:</b> Re: [llvm-dev] [AArch64] Generated assembly differs depending on whether debug information is generated or not</font>
<div> </div>
</div>
<div class="" style="word-wrap:break-word; line-break:after-white-space">Hi David,
<div class=""><br class="">
</div>
<div class="">Thanks for looking into this.</div>
<div class=""><br class="">
</div>
<div class="">It seems like D68076 might not address the underlying issue here (e.g. it probably doesn't improve the situation for projects using `-g -fno-unwind-tables`?).</div>
<div class=""><br class="">
</div>
<div class="">Would you mind elaborating a bit on your proposals to delay/change CFI instruction insertion? In particular, it'd help to hear a bit about how CFI instructions are inserted today (is some of it done by CFIInstrInserter, and the rest by target-specific
 frame lowering code?).</div>
<div class=""><br class="">
</div>
<div class="">best,</div>
<div class="">vedant<br class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Sep 26, 2019, at 6:57 AM, David Tellenbach via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a>> wrote:</div>
<br class="x_Apple-interchange-newline">
<div class=""><span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">Hi
 Paul,</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">thanks
 for your comments.</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<blockquote type="cite" class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">This is PR37240 (<a href="https://bugs.llvm.org/show_bug.cgi?id=37240" class="" style="color:purple; text-decoration:underline">https://bugs.llvm.org/show_bug.cgi?id=37240</a>). 
 I suspect this problem affects all targets; your patch D68076 would address it only for AArch64.  Although I would suggest you do some careful measurements to determine the runtime performance effect, to decide whether this is acceptable.</span></blockquote>
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">Yes,
 in principle the problem that instruction scheduling is dependent on the presence of cfi instruction should affect more targets than AArch64. However, this does not imply that all of these targets produce inconsistent assembly depending on debug information.</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<blockquote type="cite" class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">The more complete approach in your steps 2 + 3 would solve this for all targets, assuming the solution did not have to be very target-specific.  This would benefit the
 entire community.</span></blockquote>
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">At
 least 2. would require a lot of target dependent changes because the insertion of cfi instructions would have to be moved from target specific frame lowering into an (probably again target specific) insertion pass.</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">   
     David</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<div class="x_moz-cite-prefix" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
On 26/09/2019 13:55,<span class="x_Apple-converted-space"> </span><a class="x_moz-txt-link-abbreviated" href="mailto:paul.robinson@sony.com" style="color:purple; text-decoration:underline">paul.robinson@sony.com</a><span class="x_Apple-converted-space"> </span>wrote:<br class="">
</div>
<blockquote type="cite" class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; orphans:auto; text-align:start; text-indent:0px; text-transform:none; white-space:normal; widows:auto; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<div class="x_WordSection1" style="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">Hi David,</span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)"> </span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">This is PR37240 (<a href="https://bugs.llvm.org/show_bug.cgi?id=37240" class="" style="color:purple; text-decoration:underline">https://bugs.llvm.org/show_bug.cgi?id=37240</a>). 
 I suspect this problem affects all targets; your patch D68076 would address it only for AArch64.  Although I would suggest you do some careful measurements to determine the runtime performance effect, to decide whether this is acceptable.</span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)"> </span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">The more complete approach in your steps 2 + 3 would solve this for all targets, assuming the solution did not have to be very target-specific.  This would benefit the
 entire community.</span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)">--paulr</span></div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<a name="x__MailEndCompose" class=""><span class="" style="font-size:11pt; font-family:Calibri,sans-serif; color:rgb(31,73,125)"> </span></a></div>
<div class="" style="border-style:none none none solid; border-left-width:1.5pt; border-left-color:blue; padding:0in 0in 0in 4pt">
<div class="">
<div class="" style="border-style:solid none none; border-top-width:1pt; border-top-color:rgb(181,196,223); padding:3pt 0in 0in">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<b class=""><span class="" style="font-size:10pt; font-family:Tahoma,sans-serif">From:</span></b><span class="" style="font-size:10pt; font-family:Tahoma,sans-serif"><span class="x_Apple-converted-space"> </span>llvm-dev [<a class="x_moz-txt-link-freetext" href="mailto:llvm-dev-bounces@lists.llvm.org" style="color:purple; text-decoration:underline">mailto:llvm-dev-bounces@lists.llvm.org</a>]<span class="x_Apple-converted-space"> </span><b class="">On
 Behalf Of<span class="x_Apple-converted-space"> </span></b>David Tellenbach via llvm-dev<br class="">
<b class="">Sent:</b><span class="x_Apple-converted-space"> </span>Thursday, September 26, 2019 5:57 AM<br class="">
<b class="">To:</b><span class="x_Apple-converted-space"> </span>llvm-dev<br class="">
<b class="">Cc:</b><span class="x_Apple-converted-space"> </span>nd<br class="">
<b class="">Subject:</b><span class="x_Apple-converted-space"> </span>[llvm-dev] [AArch64] Generated assembly differs depending on whether debug information is generated or not</span></div>
</div>
</div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
 </div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">Hi,</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">we at Arm have noticed that assembly can differ when compiling for AArch64</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">depending on whether debug information is generated or not.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">The issue is reproducible for the following small example compiled with `-O1`</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">for `aarch64-arm-linux-gnu`:</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">    a() {</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">      b(a);</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">      for (;;)</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">        c("", b);</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">    }</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">The reason for the difference is that AArch64 frame lowering emits CFI</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">instructions if debug information is enabled but not if not. CFI instructions</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">act as scheduling boundaries during instruction scheduling and therefore lead to</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">differing scheduling regions and an overall different instruction scheduling.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">We see several ways to fix the issue and would welcome comments on this:</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">  1. Enabling unwind tables by default for AArch64: By enabling unwind tables</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     by default CFI instructions will be inserted in both, debug and non-debug</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     mode. This should lead to smaller scheduling regions and probably to less</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     scheduling potential.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     However, I've measured the average size of scheduling regions for randomly</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     generated programs with and without default unwind tables and found an</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     average difference of 0.5 to 1 instruction. Other architectures such as x86</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     do exactly this and therefore don't face the issue.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     The following patch on Phabricator introduces the said change:</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">                   <span class="x_Apple-converted-space"> </span><a class="x_moz-txt-link-freetext" href="https://reviews.llvm.org/D68076" style="color:purple; text-decoration:underline">https://reviews.llvm.org/D68076</a></span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">  2. Postpone insertion of CFI instructions until after instruction scheduling.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     This would require a new pass running after instruction scheduling that  </span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     inserts CFI instructions if needed. The downside I see is increased</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     compile-time and probably some code duplication with frame lowering.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">  3. Change instruction scheduling such that CFI instructions get tied together</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     with relevant instructions in such a way that they get scheduled together.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">     If this could work it would probably the cleanest solution.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">To summarize:</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">1. would make scheduling in the non-debug case behave like in the</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">debug case and therefore probably cost some scheduling potential. However, it</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">would be by far the most easy to implement. 2. + 3. would probably lead to</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">better scheduling but seem to be more complex to implement.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">Comments and additional ideas are welcome.</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
<div class="">
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="">    David</span><span class="" style="font-family:Calibri,sans-serif"></span></div>
</div>
<div class="" style="margin:0in 0in 0.0001pt; font-size:12pt; font-family:"Times New Roman",serif">
<span class="" style="font-family:Calibri,sans-serif"> </span></div>
</div>
</div>
</div>
</blockquote>
<br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">_______________________________________________</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important">LLVM
 Developers mailing list</span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important"><a href="mailto:llvm-dev@lists.llvm.org" class="">llvm-dev@lists.llvm.org</a></span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
<span class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none; float:none; display:inline!important"><a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" class="">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a></span><br class="" style="font-family:Helvetica; font-size:14px; font-style:normal; font-variant-caps:normal; font-weight:normal; letter-spacing:normal; text-align:start; text-indent:0px; text-transform:none; white-space:normal; word-spacing:0px; background-color:rgb(255,255,255); text-decoration:none">
</div>
</blockquote>
</div>
<br class="">
</div>
</div>
</body>
</html>