<div dir="ltr"><div></div>I am currently trying to figure out where does LLVM eliminate extraneous JMPs, like the one below.  Any hints?<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jul 26, 2014 at 12:19 PM, Vadim Chugunov <span dir="ltr"><<a href="mailto:vadimcn@gmail.com" target="_blank">vadimcn@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div>Hi All,<br><br></div>For various obscure reasons I'd like to detect the condition when X86 CALL instruction immediately precedes a function epilogue in the final emitted code, and insert a NOP between them if that happens.<br>

<br></div><div>My initial attempt at it looked like this:<br><br>MachineBasicBlock& MBB;<br>MachineBasicBlock::iterator MBBI;  <-- points to where the epilogue would be inserted <br>if (MBBI != MBB.begin() ? MBBI->getPrevNode()->isCall() :<br>

                                          MBB.getPrevNode()->back().isCall()) {<br></div><div>    // insert NOP<br></div><div>}<br><br></div><div>However, this did not work because at the stage where I am trying to do this (in X86FrameLowering::emitEpilogue), the MBBs look like this:<br>

<br></div><div>BB0: <br>    ...<br></div><div>    CALL ...   <-- call I am trying to detect<br></div><div>    EH_LABEL ...   <--| these two get eliminated in the final <br></div><div>    JMP <BB1>      <--| emitted code.<br>

<br></div><div>BB1:  <-- the MBB<br></div><div>    RET  <-- MBBI points here<br><br></div><div>So the business of finding the previous "real" instruction is starting to look very complicated.  I would need to skip over pseudo-instructions and somehow to deal with JMPs that will be eliminated later, and who knows what else...<br>

<br>My question is, am I going about it in the wrong way?    Is there an easier way to achieve what I need? <br></div><div><br></div><div>thanks!<span class="HOEnZb"><font color="#888888"><br></font></span></div><span class="HOEnZb"><font color="#888888"><div>
Vadim<br></div></font></span></div>
</blockquote></div><br></div></div></div>