<div dir="ltr">Awesome, thank you so much!! <div><br></div><div>Best,</div><div>-Stefan</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Nov 6, 2019 at 12:52 PM Joseph Tremoulet <<a href="mailto:jotrem@microsoft.com">jotrem@microsoft.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">





<div lang="EN-US">
<div class="gmail-m_-4513398348922008183WordSection1">
<p class="MsoNormal"><span style="color:rgb(31,73,125)">Yes, your understanding is correct regarding multiple incoming indirect branches.  The function in question bails on this case (see ‘findIBRPredecessor’ and the call to it) and just leaves those edges critical.<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)">-Joseph<u></u><u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><b>From:</b> Stefan Nagy <<a href="mailto:snagy2@vt.edu" target="_blank">snagy2@vt.edu</a>> <br>
<b>Sent:</b> Wednesday, November 6, 2019 12:44 PM<br>
<b>To:</b> Joseph Tremoulet <<a href="mailto:jotrem@microsoft.com" target="_blank">jotrem@microsoft.com</a>><br>
<b>Cc:</b> llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>><br>
<b>Subject:</b> Re: [llvm-dev] Seeking clarification about indirect critical edges<u></u><u></u></p>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<p class="MsoNormal">That makes way more sense, thank you so much!<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">From your description it sounds like you were assuming that “D1”, rather than “D0B”, is the original block “D”.  In the source, “D1” is “BodyBlock” and “D”/”D0”/”D0B” are “Target” (and “D0A” is “DirectSucc”).<br>
I’d guess that the “easy cases” remark corresponds to bailing out on EH pads.<u></u><u></u></p>
</blockquote>
<div>
<p class="MsoNormal">Yeah I could see how exception handling branches are a challenge, but wouldn't this also break if the critical edge is one of 2+ incoming indirect branches to its target?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">For example, if the CFG is A->D, I1->D, I2->D (assuming I1 and I2 have multiple outgoing indirect edges), we could redirect A to D0A; but because I1 and I2 both need to indirectly jump to D, we couldn't give them their own "copies" of D
 (i.e., D0B and D0C). Is my understanding correct?<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<div>
<p class="MsoNormal">Thanks,<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">-Stefan<u></u><u></u></p>
</div>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<div>
<div>
<p class="MsoNormal">On Wed, Nov 6, 2019 at 12:23 PM Joseph Tremoulet <<a href="mailto:jotrem@microsoft.com" target="_blank">jotrem@microsoft.com</a>> wrote:<u></u><u></u></p>
</div>
<blockquote style="border-top:none;border-right:none;border-bottom:none;border-left:1pt solid rgb(204,204,204);padding:0in 0in 0in 6pt;margin-left:4.8pt;margin-right:0in">
<div>
<div>
<p class="MsoNormal">What the comment doesn’t specify, but the code implements, is that “D0B” is the original block “D” (after copying/moving various things out of it as described).  That’s important
 because there’s code in the IR somewhere that gets the address of D and passes it as an argument to the indirectbr, and that dataflow may be arbitrarily complex so if the transform created some new block D0B, it wouldn’t (in the general case) be able to do
 the necessary rewrite to pass the address of D0B rather than the address of D to the indirectbr.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">From your description it sounds like you were assuming that “D1”, rather than “D0B”, is the original block “D”.  In the source, “D1” is “BodyBlock” and “D”/”D0”/”D0B” are “Target”
 (and “D0A” is “DirectSucc”).<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">I’d guess that the “easy cases” remark corresponds to bailing out on EH pads.<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal">-Joseph<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<p class="MsoNormal"><b>From:</b> llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank">llvm-dev-bounces@lists.llvm.org</a>>
<b>On Behalf Of </b>Stefan Nagy via llvm-dev<br>
<b>Sent:</b> Tuesday, November 5, 2019 6:36 PM<br>
<b>To:</b> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<b>Subject:</b> [llvm-dev] Seeking clarification about indirect critical edges<u></u><u></u></p>
<p class="MsoNormal"> <u></u><u></u></p>
<div>
<p class="MsoNormal">Hello all! (I apologize if I've ended up in the wrong list!)<br>
<br>
I'm trying to get a better understanding of LLVM's critical edge splitting, as documented in `Transforms/Utils/BasicBlockUtils.h`; specifically in the case of critical edges which are indirect transfer.<br>
<br>
The code comments discuss the following example: a CFG with direct edges A->D, B->D, and an indirect critical edge I->D; in this case two identical "dummy" nodes D0A and D0B would be inserted before D, and the edges would be re-routed as such: A->D0A, B->D0A,
 I->D0B, and D0A/D0B would just be direct jumps to D. <br>
<br>
What I'm not understanding is why it is necessary to split the non-critical edges A->D and B->D? It seems like I->D0B would handle the only edge causing us trouble in this example; since A and B are direct transfer, couldn't their jump targets just remain the
 original D? <br>
<br>
Also, the comments hint that this is only possible in some "easy cases". I'm guessing this means when D has at most one incoming indirect critical edge?<br>
<br>
Any explanation would be greatly appreciated!<br>
<br>
Thanks,<br>
-Stefan<br>
-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Stefan Nagy<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Department of Computer Science<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Virginia Tech<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<u></u><u></u></p>
<div>
<p class="MsoNormal"><u></u> <u></u></p>
</div>
<p class="MsoNormal">-- <u></u><u></u></p>
<div>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Stefan Nagy<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Department of Computer Science<u></u><u></u></p>
</div>
<div>
<p class="MsoNormal">Virginia Tech<u></u><u></u></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div>Stefan Nagy</div><div>Department of Computer Science</div><div>Virginia Tech<br></div></div></div></div></div></div>