[llvm] r256691 - [WinEH] Verify catchswitch handlers
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Sat Jan 2 07:25:26 PST 2016
Author: josepht
Date: Sat Jan 2 09:25:25 2016
New Revision: 256691
URL: http://llvm.org/viewvc/llvm-project?rev=256691&view=rev
Log:
[WinEH] Verify catchswitch handlers
Summary:
The handler list must be nonempty and consist solely of CatchPads.
Reviewers: rnk, andrew.w.kaylor, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D15842
Modified:
llvm/trunk/lib/IR/Verifier.cpp
llvm/trunk/test/Verifier/invalid-eh.ll
Modified: llvm/trunk/lib/IR/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Verifier.cpp?rev=256691&r1=256690&r2=256691&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Verifier.cpp (original)
+++ llvm/trunk/lib/IR/Verifier.cpp Sat Jan 2 09:25:25 2016
@@ -3079,6 +3079,13 @@ void Verifier::visitCatchSwitchInst(Catc
Assert(isa<ConstantTokenNone>(ParentPad) || isa<FuncletPadInst>(ParentPad),
"CatchSwitchInst has an invalid parent.", ParentPad);
+ Assert(CatchSwitch.getNumHandlers() != 0,
+ "CatchSwitchInst cannot have empty handler list", &CatchSwitch);
+
+ for (BasicBlock *Handler : CatchSwitch.handlers())
+ Assert(isa<CatchPadInst>(Handler->getFirstNonPHI()),
+ "CatchSwitchInst handlers must be catchpads", &CatchSwitch, Handler);
+
visitTerminatorInst(CatchSwitch);
}
Modified: llvm/trunk/test/Verifier/invalid-eh.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Verifier/invalid-eh.ll?rev=256691&r1=256690&r2=256691&view=diff
==============================================================================
--- llvm/trunk/test/Verifier/invalid-eh.ll (original)
+++ llvm/trunk/test/Verifier/invalid-eh.ll Sat Jan 2 09:25:25 2016
@@ -5,6 +5,7 @@
; RUN: sed -e s/.T5:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s
; RUN: sed -e s/.T6:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s
; RUN: sed -e s/.T7:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK7 %s
+; RUN: sed -e s/.T8:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK8 %s
declare void @g()
@@ -87,3 +88,11 @@ declare void @g()
;T7: catchpad within %cs2 []
;T7: unreachable
;T7: }
+
+;T8: define void @f() personality void ()* @g {
+;T8: entry:
+;T8: ret void
+;T8: switch1:
+;T8: %cs1 = catchswitch within none [ label %switch1 ] unwind to caller
+;T8: ; CHECK8: CatchSwitchInst handlers must be catchpads
+;T8: }
More information about the llvm-commits
mailing list