jump threading can't split a critical edge from an indirectbr. This
authorChris Lattner <sabre@nondot.org>
Mon, 14 Jun 2010 19:45:43 +0000 (19:45 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 14 Jun 2010 19:45:43 +0000 (19:45 +0000)
fixes PR7356.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@105950 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Scalar/JumpThreading.cpp
test/Transforms/JumpThreading/crash.ll

index 0352c6e74e34edb951ec830e6eb14e8be97031bc..1a64b2cbad7c195c75883652043203188d665ba8 100644 (file)
@@ -870,9 +870,14 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
 
     // Add all the unavailable predecessors to the PredsToSplit list.
     for (pred_iterator PI = pred_begin(LoadBB), PE = pred_end(LoadBB);
-         PI != PE; ++PI)
+         PI != PE; ++PI) {
+      // If the predecessor is an indirect goto, we can't split the edge.
+      if (isa<IndirectBrInst>((*PI)->getTerminator()))
+        return false;
+      
       if (!AvailablePredSet.count(*PI))
         PredsToSplit.push_back(*PI);
+    }
     
     // Split them out to their own block.
     UnavailablePred =
index 21620bef9ccce9cc3c5fa929c05d31a338308331..378c51a44a71a4b97a4c3f485098d404d9e80a4e 100644 (file)
@@ -341,3 +341,25 @@ if.end12:                                         ; preds = %if.then, %lbl_51
   ret void
 }
 
+
+
+; PR7356
+define i32 @test13(i32* %P, i8* %Ptr) {
+entry:
+  indirectbr i8* %Ptr, [label %BrBlock, label %B2]
+  
+B2:
+  store i32 4, i32 *%P
+  br label %BrBlock
+
+BrBlock:
+  %L = load i32* %P
+  %C = icmp eq i32 %L, 42
+  br i1 %C, label %T, label %F
+  
+T:
+  ret i32 123
+F:
+  ret i32 1422
+}
+