diff options
| author | Joseph Tremoulet <jotrem@microsoft.com> | 2015-08-23 00:26:33 +0000 |
|---|---|---|
| committer | Joseph Tremoulet <jotrem@microsoft.com> | 2015-08-23 00:26:33 +0000 |
| commit | 8220bcc5700305452e823ad2d37d769f8f15a497 (patch) | |
| tree | 3498781194fdabe5977d69f40bb8bb28514a6271 /llvm/test | |
| parent | 0732e16e690e251e92463d25b0de16c4a71a41b9 (diff) | |
| download | bcm5719-llvm-8220bcc5700305452e823ad2d37d769f8f15a497.tar.gz bcm5719-llvm-8220bcc5700305452e823ad2d37d769f8f15a497.zip | |
[WinEH] Require token linkage in EH pad/ret signatures
Summary:
WinEHPrepare is going to require that cleanuppad and catchpad produce values
of token type which are consumed by any cleanupret or catchret exiting the
pad. This change updates the signatures of those operators to require/enforce
that the type produced by the pads is token type and that the rets have an
appropriate argument.
The catchpad argument of a `CatchReturnInst` must be a `CatchPadInst` (and
similarly for `CleanupReturnInst`/`CleanupPadInst`). To accommodate that
restriction, this change adds a notion of an operator constraint to both
LLParser and BitcodeReader, allowing appropriate sentinels to be constructed
for forward references and appropriate error messages to be emitted for
illegal inputs.
Also add a verifier rule (noted in LangRef) that a catchpad with a catchpad
predecessor must have no other predecessors; this ensures that WinEHPrepare
will see the expected linear relationship between sibling catches on the
same try.
Lastly, remove some superfluous/vestigial casts from instruction operand
setters operating on BasicBlocks.
Reviewers: rnk, majnemer
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D12108
llvm-svn: 245797
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/Assembler/invalid-OperatorConstraint.ll | 59 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WinEH/wineh-demotion.ll | 80 | ||||
| -rw-r--r-- | llvm/test/CodeGen/WinEH/wineh-statenumbering.ll | 6 | ||||
| -rw-r--r-- | llvm/test/Feature/exception.ll | 102 |
4 files changed, 173 insertions, 74 deletions
diff --git a/llvm/test/Assembler/invalid-OperatorConstraint.ll b/llvm/test/Assembler/invalid-OperatorConstraint.ll new file mode 100644 index 00000000000..e21586a51bd --- /dev/null +++ b/llvm/test/Assembler/invalid-OperatorConstraint.ll @@ -0,0 +1,59 @@ +; RUN: sed -e s/.T1:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK1 %s +; RUN: sed -e s/.T2:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK2 %s +; RUN: sed -e s/.T3:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK3 %s +; RUN: sed -e s/.T4:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK4 %s +; RUN: sed -e s/.T5:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK5 %s +; RUN: sed -e s/.T6:// %s | not llvm-as -disable-output 2>&1 | FileCheck --check-prefix=CHECK6 %s + +;T1: define void @f() { +;T1: entry: +;T1: ; operator constraint requires an operator +;T1: catchret undef to label %entry +;T1: ; CHECK1: [[@LINE-1]]:15: error: Catchpad value required in this position +;T1: } + +;T2: define void @f() { +;T2: entry: +;T2: %x = cleanuppad [] +;T2: ; catchret's first operand's operator must be catchpad +;T2: catchret %x to label %entry +;T2: ; CHECK2: [[@LINE-1]]:15: error: '%x' is not a catchpad +;T2: } + +;T3: define void @f() { +;T3: entry: +;T3: ; catchret's first operand's operator must be catchpad +;T3: ; (forward reference case) +;T3: catchret %x to label %next +;T3: ; CHECK3: [[@LINE-1]]:15: error: '%x' is not a catchpad +;T3: next: +;T3: %x = cleanuppad [] +;T3: ret void +;T3: } + +;T4: define void @f() { +;T4: entry: +;T4: ; operator constraint requires an operator +;T4: cleanupret undef unwind label %entry +;T4: ; CHECK4: [[@LINE-1]]:17: error: Cleanuppad value required in this position +;T4: } + +;T5: define void @f() { +;T5: entry: +;T5: %x = catchpad [] +;T5: to label %next unwind label %entry +;T5: next: +;T5: ; cleanupret first operand's operator must be cleanuppad +;T5: cleanupret %x unwind to caller +;T5: ; CHECK5: [[@LINE-1]]:17: error: '%x' is not a cleanuppad +;T5: } + +;T6: define void @f() { +;T6: entry: +;T6: ; cleanupret's first operand's operator must be cleanuppad +;T6: ; (forward reference case) +;T6: cleanupret %x unwind label %next +;T6: ; CHECK6: [[@LINE-1]]:17: error: '%x' is not a cleanuppad +;T6: next: +;T6: %x = catchpad [] to label %entry unwind label %next +;T6: } diff --git a/llvm/test/CodeGen/WinEH/wineh-demotion.ll b/llvm/test/CodeGen/WinEH/wineh-demotion.ll index c44df6670d3..113d95015a0 100644 --- a/llvm/test/CodeGen/WinEH/wineh-demotion.ll +++ b/llvm/test/CodeGen/WinEH/wineh-demotion.ll @@ -36,14 +36,14 @@ merge: ; CHECK: merge: ; CHECK-NOT: = phi %phi = phi i32 [ %x, %left ], [ %y, %right ] - %cp = catchpad token [] to label %catch unwind label %catchend + %cp = catchpad [] to label %catch unwind label %catchend catch: ; CHECK: catch: ; CHECK: [[Reload:%[^ ]+]] = load i32, i32* [[Slot]] ; CHECK-NEXT: call void @h(i32 [[Reload]]) call void @h(i32 %phi) - catchret token %cp to label %exit + catchret %cp to label %exit catchend: catchendpad unwind to caller @@ -75,9 +75,9 @@ right: merge.inner: ; CHECK: merge.inner: ; CHECK-NOT: = phi - ; CHECK: catchpad token + ; CHECK: catchpad [] %x = phi i32 [ 1, %left ], [ 2, %right ] - %cpinner = catchpad token [] to label %catch.inner unwind label %catchend.inner + %cpinner = catchpad [] to label %catch.inner unwind label %catchend.inner catch.inner: ; Need just one store here because only %y is affected @@ -89,16 +89,16 @@ catch.inner: to label %catchret.inner unwind label %merge.outer catchret.inner: - catchret token %cpinner to label %exit + catchret %cpinner to label %exit catchend.inner: catchendpad unwind label %merge.outer merge.outer: ; CHECK: merge.outer: ; CHECK-NOT: = phi - ; CHECK: [[CatchPad:%[^ ]+]] = catchpad token + ; CHECK: [[CatchPad:%[^ ]+]] = catchpad [] %y = phi i32 [ %x, %catchend.inner ], [ %z, %catch.inner ] - %cpouter = catchpad token [] to label %catch.outer unwind label %catchend.outer + %cpouter = catchpad [] to label %catch.outer unwind label %catchend.outer catchend.outer: catchendpad unwind to caller @@ -109,10 +109,10 @@ catch.outer: ; CHECK: catch.outer: ; CHECK-DAG: load i32, i32* [[Slot1]] ; CHECK-DAG: load i32, i32* [[Slot2]] - ; CHECK: catchret token [[CatchPad]] to label + ; CHECK: catchret [[CatchPad]] to label call void @h(i32 %x) call void @h(i32 %y) - catchret token %cpouter to label %exit + catchret %cpouter to label %exit exit: ret void @@ -131,7 +131,7 @@ entry: to label %exit unwind label %catchpad catchpad: - %cp = catchpad token [] to label %catch unwind label %catchend + %cp = catchpad [] to label %catch unwind label %catchend catch: ; Need to reload %B here @@ -152,7 +152,7 @@ merge: ; CHECK: %phi = phi i32 [ [[ReloadX]], %left ] %phi = phi i32 [ %x, %left ], [ 42, %right ] call void @h(i32 %phi) - catchret token %cp to label %exit + catchret %cp to label %exit catchend: catchendpad unwind to caller @@ -188,11 +188,11 @@ right: to label %join unwind label %catchpad.inner catchpad.inner: ; CHECK: catchpad.inner: - ; CHECK-NEXT: catchpad token + ; CHECK-NEXT: catchpad [] %phi.inner = phi i32 [ %l, %left ], [ %r, %right ] - %cp1 = catchpad token [] to label %catch.inner unwind label %catchend.inner + %cp1 = catchpad [] to label %catch.inner unwind label %catchend.inner catch.inner: - catchret token %cp1 to label %join + catchret %cp1 to label %join catchend.inner: catchendpad unwind label %catchpad.outer join: @@ -205,15 +205,15 @@ join: to label %exit unwind label %catchpad.outer catchpad.outer: ; CHECK: catchpad.outer: - ; CHECK-NEXT: catchpad token + ; CHECK-NEXT: catchpad [] %phi.outer = phi i32 [ %phi.inner, %catchend.inner ], [ %j, %join ] - %cp2 = catchpad token [] to label %catch.outer unwind label %catchend.outer + %cp2 = catchpad [] to label %catch.outer unwind label %catchend.outer catch.outer: ; CHECK: catch.outer: ; CHECK: [[Reload:%[^ ]+]] = load i32, i32* [[Slot]] ; CHECK: call void @h(i32 [[Reload]]) call void @h(i32 %phi.outer) - catchret token %cp2 to label %exit + catchret %cp2 to label %exit catchend.outer: catchendpad unwind to caller exit: @@ -241,10 +241,10 @@ invoke.cont: cleanup: ; cleanup phi can be loaded at cleanup entry ; CHECK: cleanup: - ; CHECK-NEXT: cleanuppad token + ; CHECK-NEXT: cleanuppad [] ; CHECK: [[CleanupReload:%[^ ]+]] = load i32, i32* [[CleanupSlot]] %phi.cleanup = phi i32 [ 1, %entry ], [ 2, %invoke.cont ] - %cp = cleanuppad token [] + %cp = cleanuppad [] %b = call i1 @i() br i1 %b, label %left, label %right @@ -264,8 +264,8 @@ merge: ; need store for %phi.catch ; CHECK: merge: ; CHECK-NEXT: store i32 [[CleanupReload]], i32* [[CatchSlot:%[^ ]+]] - ; CHECK-NEXT: cleanupret token - cleanupret token %cp unwind label %catchpad + ; CHECK-NEXT: cleanupret + cleanupret %cp unwind label %catchpad invoke.cont2: ; need store for %phi.catch @@ -277,16 +277,16 @@ invoke.cont2: catchpad: ; CHECK: catchpad: - ; CHECK-NEXT: catchpad token + ; CHECK-NEXT: catchpad [] %phi.catch = phi i32 [ %phi.cleanup, %merge ], [ 3, %invoke.cont2 ] - %cp2 = catchpad token [] to label %catch unwind label %catchend + %cp2 = catchpad [] to label %catch unwind label %catchend catch: ; CHECK: catch: ; CHECK: [[CatchReload:%[^ ]+]] = load i32, i32* [[CatchSlot]] ; CHECK: call void @h(i32 [[CatchReload]] call void @h(i32 %phi.catch) - catchret token %cp2 to label %exit + catchret %cp2 to label %exit catchend: catchendpad unwind to caller @@ -310,8 +310,8 @@ entry: ; CHECK: store i32 %x, i32* [[SpillSlot:%[^ ]+]] ; CHECK: br label %loop to_caller: - %cp1 = cleanuppad token [] - cleanupret token %cp1 unwind to caller + %cp1 = cleanuppad [] + cleanupret %cp1 unwind to caller loop: invoke void @f() to label %loop unwind label %cleanup @@ -319,9 +319,9 @@ cleanup: ; CHECK: cleanup: ; CHECK: [[Load:%[^ ]+]] = load i32, i32* [[SpillSlot]] ; CHECK: call void @h(i32 [[Load]]) - %cp2 = cleanuppad token [] + %cp2 = cleanuppad [] call void @h(i32 %x) - cleanupret token %cp2 unwind to caller + cleanupret %cp2 unwind to caller } ; CHECK-LABEL: @test7( @@ -343,9 +343,9 @@ invoke.cont: catchpad: ; %x phi should be eliminated ; CHECK: catchpad: - ; CHECK-NEXT: %[[CatchPad:[^ ]+]] = catchpad token + ; CHECK-NEXT: %[[CatchPad:[^ ]+]] = catchpad [] %x = phi i32 [ 1, %entry ], [ 2, %invoke.cont ] - %cp = catchpad token [] to label %catch unwind label %catchend + %cp = catchpad [] to label %catch unwind label %catchend catch: %b = call i1 @i() br i1 %b, label %left, label %right @@ -353,8 +353,8 @@ left: ; Edge from %left to %join needs to be split so that ; the load of %x can be inserted *after* the catchret ; CHECK: left: - ; CHECK-NEXT: catchret token %[[CatchPad]] to label %[[SplitLeft:[^ ]+]] - catchret token %cp to label %join + ; CHECK-NEXT: catchret %[[CatchPad]] to label %[[SplitLeft:[^ ]+]] + catchret %cp to label %join ; CHECK: [[SplitLeft]]: ; CHECK: [[LoadX:%[^ ]+]] = load i32, i32* [[SlotX]] ; CHECK: br label %join @@ -363,9 +363,9 @@ right: ; the load of %y can be inserted *after* the catchret ; CHECK: right: ; CHECK: store i32 %y, i32* [[SlotY:%[^ ]+]] - ; CHECK: catchret token %[[CatchPad]] to label %[[SplitRight:[^ ]+]] + ; CHECK: catchret %[[CatchPad]] to label %[[SplitRight:[^ ]+]] %y = call i32 @g() - catchret token %cp to label %join + catchret %cp to label %join ; CHECK: [[SplitRight]]: ; CHECK: [[LoadY:%[^ ]+]] = load i32, i32* [[SlotY]] ; CHECK: br label %join @@ -392,20 +392,20 @@ done: ret void cleanup1: - ; CHECK: [[CleanupPad1:%[^ ]+]] = cleanuppad token + ; CHECK: [[CleanupPad1:%[^ ]+]] = cleanuppad [] ; CHECK-NEXT: call void @f() - ; CHECK-NEXT: cleanupret token [[CleanupPad1]] - %cp0 = cleanuppad token [] + ; CHECK-NEXT: cleanupret [[CleanupPad1]] + %cp0 = cleanuppad [] br label %cleanupexit cleanup2: - ; CHECK: cleanuppad token + ; CHECK: cleanuppad [] ; CHECK-NEXT: call void @f() ; CHECK-NEXT: unreachable - %cp1 = cleanuppad token [] + %cp1 = cleanuppad [] br label %cleanupexit cleanupexit: call void @f() - cleanupret token %cp0 unwind label %cleanup2 + cleanupret %cp0 unwind label %cleanup2 } diff --git a/llvm/test/CodeGen/WinEH/wineh-statenumbering.ll b/llvm/test/CodeGen/WinEH/wineh-statenumbering.ll index 84b56fe6411..fcbb8bd2fc3 100644 --- a/llvm/test/CodeGen/WinEH/wineh-statenumbering.ll +++ b/llvm/test/CodeGen/WinEH/wineh-statenumbering.ll @@ -37,7 +37,7 @@ entry: to label %unreachable.for.entry unwind label %catch.dispatch catch.dispatch: ; preds = %entry - %1 = catchpad token [i8* null, i8* null] to label %catch unwind label %catchendblock + %1 = catchpad [i8* null, i8* null] to label %catch unwind label %catchendblock catch: ; preds = %catch.dispatch ; CHECK: catch: @@ -47,7 +47,7 @@ catch: ; preds = %catch.dispatch to label %unreachable unwind label %catch.dispatch.1 catch.dispatch.1: ; preds = %catch - %2 = catchpad token [i8* null, i8* null] to label %catch.3 unwind label %catchendblock.2 + %2 = catchpad [i8* null, i8* null] to label %catch.3 unwind label %catchendblock.2 catch.3: ; preds = %catch.dispatch.1 ; CHECK: catch.3: @@ -57,7 +57,7 @@ catch.3: ; preds = %catch.dispatch.1 to label %invoke.cont unwind label %catchendblock.2 invoke.cont: ; preds = %catch.3 - catchret token %2 to label %try.cont + catchret %2 to label %try.cont try.cont: ; preds = %invoke.cont ; CHECK: try.cont: diff --git a/llvm/test/Feature/exception.ll b/llvm/test/Feature/exception.ll index e2635c2de42..de458bb7e4e 100644 --- a/llvm/test/Feature/exception.ll +++ b/llvm/test/Feature/exception.ll @@ -28,60 +28,100 @@ declare i32 @__gxx_personality_v0(...) define void @cleanupret0() personality i32 (...)* @__gxx_personality_v0 { entry: - br label %try.cont - -try.cont: invoke void @_Z3quxv() optsize - to label %try.cont unwind label %bb -bb: - cleanuppad void [i7 4] - cleanupret i8 0 unwind label %bb + to label %exit unwind label %pad +pad: + %cp = cleanuppad [i7 4] + cleanupret %cp unwind to caller +exit: + ret void } +; forward ref by name define void @cleanupret1() personality i32 (...)* @__gxx_personality_v0 { entry: - br label %try.cont - -try.cont: invoke void @_Z3quxv() optsize - to label %try.cont unwind label %bb -bb: - cleanuppad void [i7 4] - cleanupret void unwind label %bb + to label %exit unwind label %pad +cleanup: + cleanupret %cp unwind label %pad +pad: + %cp = cleanuppad [] + br label %cleanup +exit: + ret void } +; forward ref by ID define void @cleanupret2() personality i32 (...)* @__gxx_personality_v0 { entry: - cleanupret i8 0 unwind to caller + invoke void @_Z3quxv() optsize + to label %exit unwind label %pad +cleanup: + cleanupret %0 unwind label %pad +pad: + %0 = cleanuppad [] + br label %cleanup +exit: + ret void } -define void @cleanupret3() personality i32 (...)* @__gxx_personality_v0 { - cleanupret void unwind to caller +define void @catchret0() personality i32 (...)* @__gxx_personality_v0 { +entry: + invoke void @_Z3quxv() optsize + to label %exit unwind label %pad +pad: + %cp = catchpad [i7 4] + to label %catch unwind label %endpad +catch: + catchret %cp to label %exit +endpad: + catchendpad unwind to caller +exit: + ret void } -define void @catchret() personality i32 (...)* @__gxx_personality_v0 { +; forward ref by name +define void @catchret1() personality i32 (...)* @__gxx_personality_v0 { entry: - br label %bb -bb: - catchret void to label %bb + invoke void @_Z3quxv() optsize + to label %exit unwind label %pad +catch: + catchret %cp to label %exit +pad: + %cp = catchpad [] + to label %catch unwind label %endpad +endpad: + catchendpad unwind to caller +exit: + ret void } -define i8 @catchpad() personality i32 (...)* @__gxx_personality_v0 { +; forward ref by ID +define void @catchret2() personality i32 (...)* @__gxx_personality_v0 { entry: - br label %try.cont + invoke void @_Z3quxv() optsize + to label %exit unwind label %pad +catch: + catchret %0 to label %exit +pad: + %0 = catchpad [] + to label %catch unwind label %endpad +endpad: + catchendpad unwind to caller +exit: + ret void +} -try.cont: +define i8 @catchpad() personality i32 (...)* @__gxx_personality_v0 { +entry: invoke void @_Z3quxv() optsize to label %exit unwind label %bb2 -bb: - catchret token %cbv to label %exit - -exit: - ret i8 0 bb2: - %cbv = catchpad token [i7 4] to label %bb unwind label %bb3 + catchpad [i7 4] to label %exit unwind label %bb3 bb3: catchendpad unwind to caller +exit: + ret i8 0 } define void @terminatepad0() personality i32 (...)* @__gxx_personality_v0 { @@ -114,7 +154,7 @@ try.cont: invoke void @_Z3quxv() optsize to label %try.cont unwind label %bb bb: - cleanuppad void [i7 4] + cleanuppad [i7 4] ret void } |

