<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: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-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.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]-->
</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">Thinking about it a bit more, I don’t see why it ought to be illegal for the first non-frame-setup instruction to be a CFI directive.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">I’m not sure there are any examples except GNU_ARGS_SIZE – but I don’t think it makes sense to special-case it.<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">I’ve removed the assert in r249668.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Adrian, are you ok with that?
<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">Michael<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 0cm 0cm 0cm">
<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""> friss@apple.com [mailto:friss@apple.com]
<br>
<b>Sent:</b> Thursday, October 08, 2015 06:14<br>
<b>To:</b> Douglas Katzman<br>
<b>Cc:</b> Kuperstein, Michael M; llvm-commits@lists.llvm.org; Adrian Prantl; David Blaikie; Eric Christopher<br>
<b>Subject:</b> Re: [llvm] r249522 - [X86] Emit .cfi_escape GNU_ARGS_SIZE when adjusting the stack before calls<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Oct 7, 2015, at 6:59 PM, Douglas Katzman <<a href="mailto:dougk@google.com">dougk@google.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0cm 0cm 0cm 6.0pt;margin-left:4.8pt;margin-right:0cm">
<p class="MsoNormal">Do you happen to have a testcase handy?<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">The sanitizers on Linux comprise a test case it seems - they started failing with this commit.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><a href="http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/20647">http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/20647</a> <o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Without my understanding this code in the least, if you just do what the assertion says to do (as here), it fixes the sanitizers:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">diff --git a/lib/Target/X86/X86FrameLowering.cpp b/lib/Target/X86/X86FrameLowering.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">index 7f05e5b..d85b6a8 100644<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">--- a/lib/Target/X86/X86FrameLowering.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+++ b/lib/Target/X86/X86FrameLowering.cpp<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">@@ -384,8 +384,9 @@ void X86FrameLowering::BuildCFI(MachineBasicBlock &MBB,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">                                 MCCFIInstruction CFIInst) const {<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">   MachineFunction &MF = *MBB.getParent();<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">   unsigned CFIIndex = MF.getMMI().addFrameInst(CFIInst);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-  BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION))<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">-      .addCFIIndex(CFIIndex);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+  MachineInstrBuilder MIB = BuildMI(MBB, MBBI, DL, TII.get(TargetOpcode::CFI_INSTRUCTION));<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+  MIB.addCFIIndex(CFIIndex);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">+  MIB->setFlag(MachineInstr::FrameSetup);<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> } <o:p></o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">This will fix the assert, but I think it is conceptually wrong. FrameSetup is supposed to describe the prologue. This will insert this flag on instructions all over the function. I can’t think of any bad consequences though. CC:ing some
 other people with debug info knowledge.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Fred<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<p>---------------------------------------------------------------------<br>
Intel Israel (74) Limited</p>

<p>This e-mail and any attachments may contain confidential material for<br>
the sole use of the intended recipient(s). Any review or distribution<br>
by others is strictly prohibited. If you are not the intended<br>
recipient, please contact the sender and delete all copies.</p></body>
</html>