<div dir="ltr"><div>Hi Marina,</div><div><br></div><div>As you've highlighted, LLVM's support for inline assembly could definitely use work. It is not a well-loved area of the compiler. =/ These are some of my thoughts on what we could do.</div><div><br></div>I'd prefer to not support jumps into and out of MS inline asm blobs. I sketched out a design for doing it in <a href="http://llvm.org/pr24529#c4">http://llvm.org/pr24529#c4</a>, but it creates more LLVM IR basic blocks that have no valid insertion point. I'd like to move away from that, not towards it. MSVC doesn't even support inline asm on non-x86, so over time there will be less demand for this esoteric feature, not more.<div><br></div><div><div>I actually think supporting a terminator asm instruction for "asm goto" wouldn't be that expensive. We already have terminators like indirectbr and catchswitch that create edges that can't be split. I suspect we will want to add more to support parallel IR. Adding one for "asm goto" doesn't seem that bad, but I'm not convinced it's worth it.</div></div><div><br></div><div>Digging the symbol uses out of inline asm and the symbol definitions out of module inline asm seems totally reasonable. Adding this to the IR representation seems nice.</div><div><br></div><div>Improving our cost estimates with the help of MC would also be nice.</div><div><br></div><div>Reid</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Mar 29, 2017 at 12:37 AM, Yatsina, Marina <span dir="ltr"><<a href="mailto:marina.yatsina@intel.com" target="_blank">marina.yatsina@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">





<div lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="m_-3024031639576791680WordSection1">
<p class="MsoNormal">Hi,<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">I wanted to revive this issue of supporting asm goto (<a href="https://bugs.llvm.org/show_bug.cgi?id=9295" target="_blank"><b>Bug 9295</b></a>).<u></u><u></u></p>
<p class="MsoNormal">As was already proposed, the best way seems to be introducing new IR.<u></u><u></u></p>
<p class="MsoNormal">If we’re changing the IR, we should probably provide an infrastructure that solves or at least enables future support for things like:<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph"><u></u><span>1.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>MS-style inline asm jmps and goto (<a href="https://bugs.llvm.org/show_bug.cgi?id=24529" target="_blank"><b>Bug 24529</b></a>)<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph"><u></u><span>2.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>Analyzing symbols defined/references in the inline assembly (<a href="https://bugs.llvm.org/show_bug.cgi?id=28970" target="_blank"><b>Bug 28970</b></a>), taking into account module/file-scope inline assembly.<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph"><u></u><span>3.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>Provide some information about the cost of the inline assembly? (I’m not sure if we want to couple it with this issue and if the cost should be represented in this new IR or some other way)<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">This new IR should contain:<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph"><u></u><span>1.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>A list of symbols referenced by the inline assembly<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph" style="margin-left:72.0pt">
<u></u><span>a.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>Should we try to provide better analysis of how we use these symbols (e.g. in jmp instructions, in call instructions)? Can it help us do some error checking?<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph"><u></u><span>2.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>A list of symbols defines by the inline assembly<u></u><u></u></p>
<p class="m_-3024031639576791680MsoListParagraph" style="margin-left:72.0pt">
<u></u><span>a.<span style="font:7.0pt "Times New Roman"">     
</span></span><u></u><span dir="LTR"></span>Should we provide additional information about how symbols defined (e.g. which symbols defined as globals)?.<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">At a later stage we also need to discuss other aspects of this new instruction (e.g. it being a block terminator and other behaviors we might want to be affected by it).<u></u><u></u></p>
<p class="MsoNormal">Any other thoughts and ideas we want to include in this change that I’m missing?<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
<p class="MsoNormal">Marina<u></u><u></u></p>
</div>
<p>------------------------------<wbr>------------------------------<wbr>---------<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></div>

</blockquote></div><br></div>