[llvm] r253182 - [Sink] Don't move landingpads
Keno Fischer via llvm-commits
llvm-commits at lists.llvm.org
Sun Nov 15 20:47:58 PST 2015
Author: kfischer
Date: Sun Nov 15 22:47:58 2015
New Revision: 253182
URL: http://llvm.org/viewvc/llvm-project?rev=253182&view=rev
Log:
[Sink] Don't move landingpads
Summary: Moving landingpads into successor basic blocks makes the
verifier sad. Teach Sink that much like PHI nodes and terminator
instructions, landingpads (and cleanuppads, etc.) may not be moved
between basic blocks.
Reviewers: majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D14475
Added:
llvm/trunk/test/Transforms/Sink/landingpad.ll
Modified:
llvm/trunk/lib/Transforms/Scalar/Sink.cpp
Modified: llvm/trunk/lib/Transforms/Scalar/Sink.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/Sink.cpp?rev=253182&r1=253181&r2=253182&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/Sink.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/Sink.cpp Sun Nov 15 22:47:58 2015
@@ -169,7 +169,7 @@ static bool isSafeToMove(Instruction *In
return false;
}
- if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst))
+ if (isa<TerminatorInst>(Inst) || isa<PHINode>(Inst) || Inst->isEHPad())
return false;
// Convergent operations cannot be made control-dependent on additional
Added: llvm/trunk/test/Transforms/Sink/landingpad.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/Sink/landingpad.ll?rev=253182&view=auto
==============================================================================
--- llvm/trunk/test/Transforms/Sink/landingpad.ll (added)
+++ llvm/trunk/test/Transforms/Sink/landingpad.ll Sun Nov 15 22:47:58 2015
@@ -0,0 +1,33 @@
+; Test that we don't sink landingpads
+; RUN: opt -sink -S < %s | FileCheck %s
+
+declare hidden void @g()
+declare void @h()
+declare i32 @__gxx_personality_v0(...)
+
+define void @f() personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) {
+entry:
+ invoke void @g()
+ to label %invoke.cont.15 unwind label %lpad
+
+invoke.cont.15:
+ unreachable
+
+; CHECK: lpad:
+; CHECK: %0 = landingpad { i8*, i32 }
+lpad:
+ %0 = landingpad { i8*, i32 }
+ catch i8* null
+ invoke void @h()
+ to label %invoke.cont unwind label %lpad.1
+
+; CHECK: invoke.cont
+; CHECK-NOT: %0 = landingpad { i8*, i32 }
+invoke.cont:
+ ret void
+
+lpad.1:
+ %1 = landingpad { i8*, i32 }
+ cleanup
+ resume { i8*, i32 } %1
+}
More information about the llvm-commits
mailing list