[llvm-commits] [llvm] r94319 - in /llvm/trunk: lib/Transforms/Scalar/JumpThreading.cpp test/Transforms/JumpThreading/crash.ll

Chris Lattner sabre at nondot.org
Sat Jan 23 10:56:08 PST 2010


Author: lattner
Date: Sat Jan 23 12:56:07 2010
New Revision: 94319

URL: http://llvm.org/viewvc/llvm-project?rev=94319&view=rev
Log:
fix a crash in jump threading, PR6119

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

Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=94319&r1=94318&r2=94319&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Sat Jan 23 12:56:07 2010
@@ -451,6 +451,12 @@
 /// ProcessBlock - If there are any predecessors whose control can be threaded
 /// through to a successor, transform them now.
 bool JumpThreading::ProcessBlock(BasicBlock *BB) {
+  // If the block is trivially dead, just return and let the caller nuke it.
+  // This simplifies other transformations.
+  if (pred_begin(BB) == pred_end(BB) &&
+      BB != &BB->getParent()->getEntryBlock())
+    return false;
+  
   // If this block has a single predecessor, and if that pred has a single
   // successor, merge the blocks.  This encourages recursive jump threading
   // because now the condition in this block can be threaded through

Modified: llvm/trunk/test/Transforms/JumpThreading/crash.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/JumpThreading/crash.ll?rev=94319&r1=94318&r2=94319&view=diff

==============================================================================
--- llvm/trunk/test/Transforms/JumpThreading/crash.ll (original)
+++ llvm/trunk/test/Transforms/JumpThreading/crash.ll Sat Jan 23 12:56:07 2010
@@ -234,3 +234,28 @@
 return:     
   ret void
 }
+
+; PR6119
+define i32 @test8(i32 %action) nounwind {
+entry:
+  switch i32 %action, label %lor.rhs [
+    i32 1, label %if.then
+    i32 0, label %lor.end
+  ]
+
+if.then:                                          ; preds = %for.cond, %lor.end, %entry
+  ret i32 undef
+
+lor.rhs:                                          ; preds = %entry
+  br label %lor.end
+
+lor.end:                                          ; preds = %lor.rhs, %entry
+  %cmp103 = xor i1 undef, undef                   ; <i1> [#uses=1]
+  br i1 %cmp103, label %for.cond, label %if.then
+
+for.cond:                                         ; preds = %for.body, %lor.end
+  br i1 undef, label %if.then, label %for.body
+
+for.body:                                         ; preds = %for.cond
+  br label %for.cond
+}





More information about the llvm-commits mailing list