From 3e1cca7ad0cc730b54c1a2057f9ce36a85eab75a Mon Sep 17 00:00:00 2001 From: Nico Weber Date: Fri, 27 Feb 2015 16:40:43 +0000 Subject: [PATCH] Reland __leave tests (r230717 and r230720, reverted in r230740). The only change is that line 266 changed from // CHECK: br label %[[except]] to // CHECK: br label %[[except:[^ ]*]] git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@230764 91177308-0d34-0410-b5e6-96231b3b80d8 --- test/CodeGen/exceptions-seh-leave.c | 135 +++++++++++++++++++++++++++- 1 file changed, 133 insertions(+), 2 deletions(-) diff --git a/test/CodeGen/exceptions-seh-leave.c b/test/CodeGen/exceptions-seh-leave.c index 7901c8c2fb..f88380b227 100644 --- a/test/CodeGen/exceptions-seh-leave.c +++ b/test/CodeGen/exceptions-seh-leave.c @@ -125,8 +125,6 @@ int __leave_with___finally() { ////////////////////////////////////////////////////////////////////////////// // Mixed, nested cases. -// FIXME: Test with outer __finally once PR22553 is fixed. - int nested___except___finally() { int myres = 0; __try { @@ -237,3 +235,136 @@ int nested___except___except() { // CHECK: [[tryleave]] // CHECK-NEXT: br label %[[trycont4]] + +int nested___finally___except() { + int myres = 0; + __try { + __try { + g(); + } __except (1) { + g(); + __leave; // Refers to the outer __try, not the __except! + myres = 23; + return 0; + } + + myres = 51; + } __finally { + } + return 1; +} +// The order of basic blocks in the below doesn't matter. +// CHECK-LABEL: define i32 @nested___finally___except() + +// CHECK-LABEL: invoke void bitcast (void (...)* @g to void ()*)() +// CHECK-NEXT: to label %[[g1_cont:.*]] unwind label %[[g1_lpad:.*]] + +// CHECK: [[g1_cont]] +// CHECK-NEXT: br label %[[trycont:[^ ]*]] + +// CHECK: [[g1_lpad]] +// CHECK: br label %[[except:[^ ]*]] + +// CHECK: [[except]] +// CHECK-NEXT: invoke void bitcast (void (...)* @g to void ()*)() +// CHECK-NEXT: to label %[[g2_cont:.*]] unwind label %[[g2_lpad:.*]] + +// CHECK: [[g2_cont]] +// CHECK-NEXT: br label %[[tryleave:[^ ]*]] +// CHECK-NOT: 23 + +// CHECK: [[g2_lpad]] +// CHECK: store i8 1, i8* %[[abnormal:[^ ]*]] +// CHECK-NEXT: br label %[[finally:[^ ]*]] + +// CHECK: [[trycont]] +// CHECK: store i32 51, i32* % +// CHECK-NEXT: br label %[[tryleave]] + +// CHECK: [[tryleave]] +// CHECK-NEXT: store i8 0, i8* %[[abnormal]] +// CHECK-NEXT: br label %[[finally:[^ ]*]] + +// CHECK: [[finally]] +// CHECK-NEXT: %[[abnormallocal:[^ ]*]] = load i8* %[[abnormal]] +// CHECK-NEXT: %[[reg:[^ ]*]] = icmp eq i8 %[[abnormallocal]], 0 +// CHECK-NEXT: br i1 %[[reg]], label %[[finallycont:[^ ]*]], label %[[finallyresume:[^ ]*]] + +// CHECK: [[finallycont]] +// CHECK-NEXT: ret i32 1 + +// CHECK: [[finallyresume]] +// CHECK-NEXT: br label %[[ehresume:[^ ]*]] + +// CHECK: [[ehresume]] +// CHECK: resume + +int nested___finally___finally() { + int myres = 0; + __try { + __try { + g(); + myres = 16; + } __finally { + g(); + __leave; // Refers to the outer __try, not the __finally we're in! + myres = 23; + return 0; + } + + myres = 51; + } __finally { + } + return 1; +} +// The order of basic blocks in the below doesn't matter. +// CHECK-LABEL: define i32 @nested___finally___finally() + +// CHECK-LABEL: invoke void bitcast (void (...)* @g to void ()*)() +// CHECK-NEXT: to label %[[g1_cont:.*]] unwind label %[[g1_lpad:.*]] + +// CHECK: [[g1_cont]] +// CHECK: store i32 16, i32* %[[myres:[^ ]*]], +// CHECK: store i8 0, i8* %[[abnormal:[^ ]*]] +// CHECK-NEXT: br label %[[finally:[^ ]*]] + +// CHECK: [[finally]] +// CHECK-NEXT: invoke void bitcast (void (...)* @g to void ()*)() #3 +// CHECK-NEXT: to label %[[g2_cont:.*]] unwind label %[[g2_lpad:.*]] + +// CHECK: [[g2_cont]] +// CHECK-NEXT: br label %[[tryleave:[^ ]*]] +// CHECK-NOT: store i32 23 + +// There's an unreachable block for the skipped `myres = 51`. +// CHECK: store i32 51, i32* %[[myres]] +// CHECK-NEXT: br label %[[tryleave]] + +// CHECK: [[tryleave]] +// CHECK-NEXT: store i8 0, i8* %[[abnormal]] +// CHECK-NEXT: br label %[[outerfinally:[^ ]*]] + +// CHECK: [[outerfinally]] +// CHECK-NEXT: %[[abnormallocal:[^ ]*]] = load i8* %[[abnormal]] +// CHECK-NEXT: %[[reg:[^ ]*]] = icmp eq i8 %[[abnormallocal]], 0 +// CHECK-NEXT: br i1 %[[reg]], label %[[finallycont:[^ ]*]], label %[[finallyresume:[^ ]*]] + +// CHECK: [[finallycont]] +// CHECK-NEXT: ret i32 1 + +// CHECK: [[g1_lpad]] +// CHECK: store i8 1, i8* %[[abnormal]] +// CHECK-NEXT: br label %[[finally:[^ ]*]] + +// CHECK: [[g2_lpad]] +// CHECK: br label %[[ehcleanup:[^ ]*]] + +// CHECK: [[ehcleanup]] +// CHECK-NEXT: store i8 1, i8* %[[abnormal]] +// CHECK-NEXT: br label %[[outerfinally]] + +// CHECK: [[finallyresume]] +// CHECK-NEXT: br label %[[ehresume:[^ ]*]] + +// CHECK: [[ehresume]] +// CHECK: resume -- 2.40.0