<div dir="ltr">The variable LatchBR is unused in Release builds and throws a warning.</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature">~Craig</div></div>
<br><div class="gmail_quote">On Wed, May 3, 2017 at 10:44 AM, Anna Thomas via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: annat<br>
Date: Wed May  3 12:43:59 2017<br>
New Revision: 302058<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=302058&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=302058&view=rev</a><br>
Log:<br>
[RuntimeLoopUnroller] Add assert that we dont unroll non-rotated loops<br>
<br>
Summary:<br>
Cloning basic blocks in the loop for runtime loop unroller depends on loop being<br>
in rotated form (i.e. loop latch target is the exit block).<br>
Assert that this is true, so that callers of runtime loop unroller pass in<br>
canonical loops.<br>
The single caller of this function has that check recently added:<br>
<a href="https://reviews.llvm.org/rL301239" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>rL301239</a><br>
<br>
Reviewers: davide<br>
<br>
Subscribers: llvm-commits<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D32801" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D32801</a><br>
<br>
Modified:<br>
    llvm/trunk/lib/Transforms/<wbr>Utils/LoopUnrollRuntime.cpp<br>
<br>
Modified: llvm/trunk/lib/Transforms/<wbr>Utils/LoopUnrollRuntime.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/LoopUnrollRuntime.cpp?rev=302058&r1=302057&r2=302058&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/llvm/trunk/lib/<wbr>Transforms/Utils/<wbr>LoopUnrollRuntime.cpp?rev=<wbr>302058&r1=302057&r2=302058&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- llvm/trunk/lib/Transforms/<wbr>Utils/LoopUnrollRuntime.cpp (original)<br>
+++ llvm/trunk/lib/Transforms/<wbr>Utils/LoopUnrollRuntime.cpp Wed May  3 12:43:59 2017<br>
@@ -512,6 +512,13 @@ bool llvm::<wbr>UnrollRuntimeLoopRemainder(Lo<br>
<br>
   BasicBlock *Latch = L->getLoopLatch();<br>
<br>
+  // Cloning the loop basic blocks (`CloneLoopBlocks`) requires that one of the<br>
+  // targets of the Latch be the single exit block out of the loop. This needs<br>
+  // to be guaranteed by the callers of UnrollRuntimeLoopRemainder.<br>
+  BranchInst *LatchBR = cast<BranchInst>(Latch-><wbr>getTerminator());<br>
+  assert(LatchBR->getSuccessor(<wbr>0) == Exit ||<br>
+         LatchBR->getSuccessor(1) == Exit && "loop latch successor should be "<br>
+                                             "exit block!");<br>
   // Loop structure is the following:<br>
   //<br>
   // PreHeader<br>
<br>
<br>
______________________________<wbr>_________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>