[llvm-commits] [llvm] r58385 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
Chris Lattner
sabre at nondot.org
Wed Oct 29 10:46:26 PDT 2008
Author: lattner
Date: Wed Oct 29 12:46:26 2008
New Revision: 58385
URL: http://llvm.org/viewvc/llvm-project?rev=58385&view=rev
Log:
Fix PR2967 by not deleting volatile load/stores that occur before unreachable.
I don't really see this as being needed, but there is little harm from doing
it.
Added:
llvm/trunk/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
Modified:
llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
Modified: llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp?rev=58385&r1=58384&r2=58385&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp (original)
+++ llvm/trunk/lib/Transforms/Utils/SimplifyCFG.cpp Wed Oct 29 12:46:26 2008
@@ -1932,7 +1932,18 @@
while (Unreachable != BB->begin()) {
BasicBlock::iterator BBI = Unreachable;
--BBI;
+ // Do not delete instructions that can have side effects, like calls
+ // (which may never return) and volatile loads and stores.
if (isa<CallInst>(BBI)) break;
+
+ if (StoreInst *SI = dyn_cast<StoreInst>(BBI))
+ if (SI->isVolatile())
+ break;
+
+ if (LoadInst *LI = dyn_cast<LoadInst>(BBI))
+ if (LI->isVolatile())
+ break;
+
// Delete this instruction
BB->getInstList().erase(BBI);
Changed = true;
Added: llvm/trunk/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll?rev=58385&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll (added)
+++ llvm/trunk/test/Transforms/SimplifyCFG/trapping-load-unreachable.ll Wed Oct 29 12:46:26 2008
@@ -0,0 +1,19 @@
+; RUN: llvm-as < %s | opt -simplifycfg | llvm-dis | grep {volatile load}
+; PR2967
+
+target datalayout =
+"e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32"
+target triple = "i386-pc-linux-gnu"
+
+define void @foo(i32 %x) nounwind {
+entry:
+ %0 = icmp eq i32 %x, 0 ; <i1> [#uses=1]
+ br i1 %0, label %bb, label %return
+
+bb: ; preds = %entry
+ %1 = volatile load i32* null ; <i32> [#uses=0]
+ unreachable
+ br label %return
+return: ; preds = %entry
+ ret void
+}
More information about the llvm-commits
mailing list