summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJoseph Tremoulet <jotrem@microsoft.com>2016-01-10 04:28:38 +0000
committerJoseph Tremoulet <jotrem@microsoft.com>2016-01-10 04:28:38 +0000
commite28885e6936fc5487c9e11cda841282d2f43c9d1 (patch)
treeaed0a61d8bcf0063bd4a529d7be2338b6ae3be74 /llvm/test
parentca4d93a82fd77b1baadc7f604cd97ed0bafcb717 (diff)
downloadbcm5719-llvm-e28885e6936fc5487c9e11cda841282d2f43c9d1.tar.gz
bcm5719-llvm-e28885e6936fc5487c9e11cda841282d2f43c9d1.zip
[WinEH] Verify unwind edges against EH pad tree
Summary: Funclet EH personalities require a tree-like nesting among funclets (enforced by the ParentPad linkage in the IR), and also require that unwind edges conform to certain rules with respect to the tree: - An unwind edge may exit 0 or more ancestor pads - An unwind edge must enter exactly one EH pad, which must be distinct from any exited pads - A cleanupret's edge must exit its cleanuppad Describe these rules in the LangRef, and enforce them in the verifier. Reviewers: rnk, majnemer, andrew.w.kaylor Subscribers: llvm-commits Differential Revision: http://reviews.llvm.org/D15961 llvm-svn: 257272
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/Bitcode/compatibility.ll3
-rw-r--r--llvm/test/Feature/exception.ll4
-rw-r--r--llvm/test/Verifier/invalid-eh.ll87
3 files changed, 91 insertions, 3 deletions
diff --git a/llvm/test/Bitcode/compatibility.ll b/llvm/test/Bitcode/compatibility.ll
index 34c4a073b54..ae12a24ede4 100644
--- a/llvm/test/Bitcode/compatibility.ll
+++ b/llvm/test/Bitcode/compatibility.ll
@@ -885,7 +885,8 @@ catchpad:
; CHECK-NEXT: br label %body
body:
- invoke void @f.ccc() to label %continue unwind label %terminate.inner
+ invoke void @f.ccc() [ "funclet"(token %catch) ]
+ to label %continue unwind label %terminate.inner
catchret from %catch to label %return
; CHECK: catchret from %catch to label %return
diff --git a/llvm/test/Feature/exception.ll b/llvm/test/Feature/exception.ll
index 2634692f425..cbe2d0353cc 100644
--- a/llvm/test/Feature/exception.ll
+++ b/llvm/test/Feature/exception.ll
@@ -43,7 +43,7 @@ entry:
invoke void @_Z3quxv() optsize
to label %exit unwind label %pad
cleanup:
- cleanupret from %cp unwind label %pad
+ cleanupret from %cp unwind to caller
pad:
%cp = cleanuppad within none []
br label %cleanup
@@ -57,7 +57,7 @@ entry:
invoke void @_Z3quxv() optsize
to label %exit unwind label %pad
cleanup:
- cleanupret from %0 unwind label %pad
+ cleanupret from %0 unwind to caller
pad:
%0 = cleanuppad within none []
br label %cleanup
diff --git a/llvm/test/Verifier/invalid-eh.ll b/llvm/test/Verifier/invalid-eh.ll
index 21e88d4dcb3..e43a676495d 100644
--- a/llvm/test/Verifier/invalid-eh.ll
+++ b/llvm/test/Verifier/invalid-eh.ll
@@ -6,6 +6,11 @@
; 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
+; RUN: sed -e s/.T9:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK9 %s
+; RUN: sed -e s/.T10:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK10 %s
+; RUN: sed -e s/.T11:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK11 %s
+; RUN: sed -e s/.T12:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK12 %s
+; RUN: sed -e s/.T13:// %s | not opt -verify -disable-output 2>&1 | FileCheck --check-prefix=CHECK13 %s
declare void @g()
@@ -96,3 +101,85 @@ declare void @g()
;T8: %cs1 = catchswitch within none [ label %switch1 ] unwind to caller
;T8: ; CHECK8: CatchSwitchInst handlers must be catchpads
;T8: }
+
+;T9: define void @f() personality void ()* @g {
+;T9: entry:
+;T9: ret void
+;T9: cleanup:
+;T9: %cp = cleanuppad within none []
+;T9: invoke void @g() [ "funclet"(token %cp) ]
+;T9: to label %exit unwind label %cleanup
+;T9: ; CHECK9: EH pad cannot handle exceptions raised within it
+;T9: ; CHECK9-NEXT: %cp = cleanuppad within none []
+;T9: ; CHECK9-NEXT: invoke void @g() [ "funclet"(token %cp) ]
+;T9: exit:
+;T9: ret void
+;T9: }
+
+;T10: define void @f() personality void ()* @g {
+;T10: entry:
+;T10: ret void
+;T10: cleanup1:
+;T10: %cp1 = cleanuppad within none []
+;T10: unreachable
+;T10: switch:
+;T10: %cs = catchswitch within %cp1 [label %catch] unwind to caller
+;T10: catch:
+;T10: %catchp1 = catchpad within %cs [i32 1]
+;T10: unreachable
+;T10: cleanup2:
+;T10: %cp2 = cleanuppad within %catchp1 []
+;T10: unreachable
+;T10: cleanup3:
+;T10: %cp3 = cleanuppad within %cp2 []
+;T10: cleanupret from %cp3 unwind label %switch
+;T10: ; CHECK10: EH pad cannot handle exceptions raised within it
+;T10: ; CHECK10-NEXT: %cs = catchswitch within %cp1 [label %catch] unwind to caller
+;T10: ; CHECK10-NEXT: cleanupret from %cp3 unwind label %switch
+;T10: }
+
+;T11: define void @f() personality void ()* @g {
+;T11: entry:
+;T11: ret void
+;T11: cleanup1:
+;T11: %cp1 = cleanuppad within none []
+;T11: unreachable
+;T11: cleanup2:
+;T11: %cp2 = cleanuppad within %cp1 []
+;T11: unreachable
+;T11: switch:
+;T11: %cs = catchswitch within none [label %catch] unwind label %cleanup2
+;T11: ; CHECK11: A single unwind edge may only enter one EH pad
+;T11: ; CHECK11-NEXT: %cs = catchswitch within none [label %catch] unwind label %cleanup2
+;T11: catch:
+;T11: catchpad within %cs [i32 1]
+;T11: unreachable
+;T11: }
+
+;T12: define void @f() personality void ()* @g {
+;T12: entry:
+;T12: ret void
+;T12: cleanup:
+;T12: %cp = cleanuppad within none []
+;T12: cleanupret from %cp unwind label %switch
+;T12: ; CHECK12: A cleanupret must exit its cleanup
+;T12: ; CHECK12-NEXT: cleanupret from %cp unwind label %switch
+;T12: switch:
+;T12: %cs = catchswitch within %cp [label %catch] unwind to caller
+;T12: catch:
+;T12: catchpad within %cs [i32 1]
+;T12: unreachable
+;T12: }
+
+;T13: define void @f() personality void ()* @g {
+;T13: entry:
+;T13: ret void
+;T13: switch:
+;T13: %cs = catchswitch within none [label %catch] unwind label %switch
+;T13: ; CHECK13: EH pad cannot handle exceptions raised within it
+;T13: ; CHECK13-NEXT: %cs = catchswitch within none [label %catch] unwind label %switch
+;T13: catch:
+;T13: catchpad within %cs [i32 0]
+;T13: unreachable
+;T13: }
+
OpenPOWER on IntegriCloud