[llvm] r230058 - LoopRotate: When reconstructing loop simplify form don't split edges from indirectbrs.

Benjamin Kramer benny.kra at googlemail.com
Fri Feb 20 12:49:25 PST 2015


Author: d0k
Date: Fri Feb 20 14:49:25 2015
New Revision: 230058

URL: http://llvm.org/viewvc/llvm-project?rev=230058&view=rev
Log:
LoopRotate: When reconstructing loop simplify form don't split edges from indirectbrs.

Yet another chapter in the endless story. While this looks like we leave
the loop in a non-canonical state this replicates the logic in
LoopSimplify so it doesn't diverge from the canonical form in any way.

PR21968

Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
    llvm/trunk/test/Transforms/LoopRotate/crash.ll

Modified: llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp?rev=230058&r1=230057&r2=230058&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopRotation.cpp Fri Feb 20 14:49:25 2015
@@ -535,6 +535,8 @@ bool LoopRotate::rotateLoop(Loop *L, boo
       Loop *PredLoop = LI->getLoopFor(*PI);
       if (!PredLoop || PredLoop->contains(Exit))
         continue;
+      if (isa<IndirectBrInst>((*PI)->getTerminator()))
+        continue;
       SplitLatchEdge |= L->getLoopLatch() == *PI;
       BasicBlock *ExitSplit = SplitCriticalEdge(
           *PI, Exit, CriticalEdgeSplittingOptions(DT, LI).setPreserveLCSSA());

Modified: llvm/trunk/test/Transforms/LoopRotate/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopRotate/crash.ll?rev=230058&r1=230057&r2=230058&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/LoopRotate/crash.ll (original)
+++ llvm/trunk/test/Transforms/LoopRotate/crash.ll Fri Feb 20 14:49:25 2015
@@ -153,3 +153,21 @@ entry:
 "5":                                              ; preds = %"3", %entry
   ret void
 }
+
+; PR21968
+define void @test8(i1 %C, i8* %P) #0 {
+entry:
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.inc, %entry
+  br i1 %C, label %l_bad, label %for.body
+
+for.body:                                         ; preds = %for.cond
+  indirectbr i8* %P, [label %for.inc, label %l_bad]
+
+for.inc:                                          ; preds = %for.body
+  br label %for.cond
+
+l_bad:                                            ; preds = %for.body, %for.cond
+  ret void
+}





More information about the llvm-commits mailing list