[PATCH] D15842: [WinEH] Verify catchswitch handlers
Joseph Tremoulet via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 1 17:27:19 PST 2016
JosephTremoulet created this revision.
JosephTremoulet added reviewers: rnk, majnemer, andrew.w.kaylor.
JosephTremoulet added a subscriber: llvm-commits.
The handler list must be nonempty and consist solely of CatchPads.
http://reviews.llvm.org/D15842
Files:
lib/IR/Verifier.cpp
test/Verifier/invalid-eh.ll
Index: test/Verifier/invalid-eh.ll
===================================================================
--- test/Verifier/invalid-eh.ll
+++ test/Verifier/invalid-eh.ll
@@ -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 @@
;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: }
Index: lib/IR/Verifier.cpp
===================================================================
--- lib/IR/Verifier.cpp
+++ lib/IR/Verifier.cpp
@@ -3081,6 +3081,13 @@
isa<CatchPadInst>(ParentPad),
"CatchSwitchInst has an invalid parent.", ParentPad);
+ Assert(CatchSwitch.getNumHandlers(),
+ "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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15842.43842.patch
Type: text/x-patch
Size: 1582 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160102/c737c6b6/attachment.bin>
More information about the llvm-commits
mailing list