2016-02-20 17:23:41 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | opt -instnamer -S | FileCheck %s
|
Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.
Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
implemented.
- __finally blocks will not run after exceptions. Fixing this requires
work in the LLVM SEH preparation pass.
The IR lowering looks like this:
// C code:
bool safe_div(int n, int d, int *r) {
__try {
*r = normal_div(n, d);
} __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
return false;
}
return true;
}
; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
%ehptrs = bitcast i8* %e to i32**
%ehrec = load i32** %ehptrs
%code = load i32* %ehrec
%matches = icmp eq i32 %code, i32 u0xC0000094
%matches.i32 = zext i1 %matches to i32
ret i32 %matches.i32
}
define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
%rr = invoke i32 @normal_div(i32 %n, i32 %d)
to label %normal unwind to label %lpad
normal:
store i32 %rr, i32* %r
ret i1 1
lpad:
%ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
%ehptr = extractvalue {i8*, i32} %ehvals, i32 0
%sel = extractvalue {i8*, i32} %ehvals, i32 1
%filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
%matches = icmp eq i32 %sel, %filter_sel
br i1 %matches, label %eh.except, label %eh.resume
eh.except:
ret i1 false
eh.resume:
resume
}
Reviewers: rjmccall, rsmith, majnemer
Differential Revision: http://reviews.llvm.org/D5607
llvm-svn: 226760
2015-01-22 09:36:17 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
void g(void);
|
Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.
Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
implemented.
- __finally blocks will not run after exceptions. Fixing this requires
work in the LLVM SEH preparation pass.
The IR lowering looks like this:
// C code:
bool safe_div(int n, int d, int *r) {
__try {
*r = normal_div(n, d);
} __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
return false;
}
return true;
}
; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
%ehptrs = bitcast i8* %e to i32**
%ehrec = load i32** %ehptrs
%code = load i32* %ehrec
%matches = icmp eq i32 %code, i32 u0xC0000094
%matches.i32 = zext i1 %matches to i32
ret i32 %matches.i32
}
define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
%rr = invoke i32 @normal_div(i32 %n, i32 %d)
to label %normal unwind to label %lpad
normal:
store i32 %rr, i32* %r
ret i1 1
lpad:
%ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
%ehptr = extractvalue {i8*, i32} %ehvals, i32 0
%sel = extractvalue {i8*, i32} %ehvals, i32 1
%filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
%matches = icmp eq i32 %sel, %filter_sel
br i1 %matches, label %eh.except, label %eh.resume
eh.except:
ret i1 false
eh.resume:
resume
}
Reviewers: rjmccall, rsmith, majnemer
Differential Revision: http://reviews.llvm.org/D5607
llvm-svn: 226760
2015-01-22 09:36:17 +08:00
|
|
|
|
2015-02-13 07:16:11 +08:00
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// __leave with __except
|
|
|
|
|
|
|
|
// Nothing in the __try block can trap, so __try.cont isn't created.
|
|
|
|
int __leave_with___except_simple() {
|
Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.
Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
implemented.
- __finally blocks will not run after exceptions. Fixing this requires
work in the LLVM SEH preparation pass.
The IR lowering looks like this:
// C code:
bool safe_div(int n, int d, int *r) {
__try {
*r = normal_div(n, d);
} __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
return false;
}
return true;
}
; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
%ehptrs = bitcast i8* %e to i32**
%ehrec = load i32** %ehptrs
%code = load i32* %ehrec
%matches = icmp eq i32 %code, i32 u0xC0000094
%matches.i32 = zext i1 %matches to i32
ret i32 %matches.i32
}
define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
%rr = invoke i32 @normal_div(i32 %n, i32 %d)
to label %normal unwind to label %lpad
normal:
store i32 %rr, i32* %r
ret i1 1
lpad:
%ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
%ehptr = extractvalue {i8*, i32} %ehvals, i32 0
%sel = extractvalue {i8*, i32} %ehvals, i32 1
%filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
%matches = icmp eq i32 %sel, %filter_sel
br i1 %matches, label %eh.except, label %eh.resume
eh.except:
ret i1 false
eh.resume:
resume
}
Reviewers: rjmccall, rsmith, majnemer
Differential Revision: http://reviews.llvm.org/D5607
llvm-svn: 226760
2015-01-22 09:36:17 +08:00
|
|
|
int myres = 0;
|
|
|
|
__try {
|
2015-02-13 07:16:11 +08:00
|
|
|
myres = 15;
|
Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.
Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
implemented.
- __finally blocks will not run after exceptions. Fixing this requires
work in the LLVM SEH preparation pass.
The IR lowering looks like this:
// C code:
bool safe_div(int n, int d, int *r) {
__try {
*r = normal_div(n, d);
} __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
return false;
}
return true;
}
; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
%ehptrs = bitcast i8* %e to i32**
%ehrec = load i32** %ehptrs
%code = load i32* %ehrec
%matches = icmp eq i32 %code, i32 u0xC0000094
%matches.i32 = zext i1 %matches to i32
ret i32 %matches.i32
}
define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
%rr = invoke i32 @normal_div(i32 %n, i32 %d)
to label %normal unwind to label %lpad
normal:
store i32 %rr, i32* %r
ret i1 1
lpad:
%ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
%ehptr = extractvalue {i8*, i32} %ehvals, i32 0
%sel = extractvalue {i8*, i32} %ehvals, i32 1
%filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
%matches = icmp eq i32 %sel, %filter_sel
br i1 %matches, label %eh.except, label %eh.resume
eh.except:
ret i1 false
eh.resume:
resume
}
Reviewers: rjmccall, rsmith, majnemer
Differential Revision: http://reviews.llvm.org/D5607
llvm-svn: 226760
2015-01-22 09:36:17 +08:00
|
|
|
__leave;
|
2015-02-13 07:16:11 +08:00
|
|
|
myres = 23;
|
Initial support for Win64 SEH IR emission
The lowering looks a lot like normal EH lowering, with the exception
that the exceptions are caught by executing filter expression code
instead of matching typeinfo globals. The filter expressions are
outlined into functions which are used in landingpad clauses where
typeinfo would normally go.
Major aspects that still need work:
- Non-call exceptions in __try bodies won't work yet. The plan is to
outline the __try block in the frontend to keep things simple.
- Filter expressions cannot use local variables until capturing is
implemented.
- __finally blocks will not run after exceptions. Fixing this requires
work in the LLVM SEH preparation pass.
The IR lowering looks like this:
// C code:
bool safe_div(int n, int d, int *r) {
__try {
*r = normal_div(n, d);
} __except(_exception_code() == EXCEPTION_INT_DIVIDE_BY_ZERO) {
return false;
}
return true;
}
; LLVM IR:
define i32 @filter(i8* %e, i8* %fp) {
%ehptrs = bitcast i8* %e to i32**
%ehrec = load i32** %ehptrs
%code = load i32* %ehrec
%matches = icmp eq i32 %code, i32 u0xC0000094
%matches.i32 = zext i1 %matches to i32
ret i32 %matches.i32
}
define i1 zeroext @safe_div(i32 %n, i32 %d, i32* %r) {
%rr = invoke i32 @normal_div(i32 %n, i32 %d)
to label %normal unwind to label %lpad
normal:
store i32 %rr, i32* %r
ret i1 1
lpad:
%ehvals = landingpad {i8*, i32} personality i32 (...)* @__C_specific_handler
catch i8* bitcast (i32 (i8*, i8*)* @filter to i8*)
%ehptr = extractvalue {i8*, i32} %ehvals, i32 0
%sel = extractvalue {i8*, i32} %ehvals, i32 1
%filter_sel = call i32 @llvm.eh.seh.typeid.for(i8* bitcast (i32 (i8*, i8*)* @filter to i8*))
%matches = icmp eq i32 %sel, %filter_sel
br i1 %matches, label %eh.except, label %eh.resume
eh.except:
ret i1 false
eh.resume:
resume
}
Reviewers: rjmccall, rsmith, majnemer
Differential Revision: http://reviews.llvm.org/D5607
llvm-svn: 226760
2015-01-22 09:36:17 +08:00
|
|
|
} __except (1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @__leave_with___except_simple()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK: store i32 15, i32* %myres
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NOT: store i32 23
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: ret i32 1
|
|
|
|
|
|
|
|
|
|
|
|
// The "normal" case.
|
|
|
|
int __leave_with___except() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
g();
|
|
|
|
__leave;
|
|
|
|
myres = 23;
|
|
|
|
} __except (1) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @__leave_with___except()
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: invoke void @g()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: to label %[[cont:.*]] unwind label %{{.*}}
|
|
|
|
// For __excepts, instead of an explicit __try.__leave label, we could use
|
|
|
|
// use invoke.cont as __leave jump target instead. However, not doing this
|
|
|
|
// keeps the CodeGen code simpler, __leave is very rare, and SimplifyCFG will
|
|
|
|
// simplify this anyways.
|
|
|
|
// CHECK: [[cont]]
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NOT: store i32 23
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
|
|
|
// CHECK-NEXT: br label %
|
2015-02-13 07:16:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// __leave with __finally
|
|
|
|
|
|
|
|
void abort(void) __attribute__((noreturn));
|
|
|
|
|
|
|
|
// Nothing in the __try block can trap, so __finally.cont and friends aren't
|
|
|
|
// created.
|
|
|
|
int __leave_with___finally_simple() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
myres = 15;
|
|
|
|
__leave;
|
|
|
|
myres = 23;
|
|
|
|
} __finally {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @__leave_with___finally_simple()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK: store i32 15, i32* %myres
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NOT: store i32 23
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@__leave_with___finally_simple@@"(i8 0, i8* %[[fp]])
|
2015-02-13 07:16:11 +08:00
|
|
|
|
|
|
|
// __finally block doesn't return, __finally.cont doesn't exist.
|
|
|
|
int __leave_with___finally_noreturn() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
myres = 15;
|
|
|
|
__leave;
|
|
|
|
myres = 23;
|
|
|
|
} __finally {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @__leave_with___finally_noreturn()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK: store i32 15, i32* %myres
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NOT: store i32 23
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@__leave_with___finally_noreturn@@"(i8 0, i8* %[[fp]])
|
2015-02-13 07:16:11 +08:00
|
|
|
|
|
|
|
// The "normal" case.
|
|
|
|
int __leave_with___finally() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
g();
|
|
|
|
__leave;
|
|
|
|
myres = 23;
|
|
|
|
} __finally {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @__leave_with___finally()
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: invoke void @g()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: to label %[[cont:.*]] unwind label %{{.*}}
|
|
|
|
// For __finally, there needs to be an explicit __try.__leave, because
|
|
|
|
// abnormal.termination.slot needs to be set there.
|
|
|
|
// CHECK: [[cont]]
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NOT: store i32 23
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@__leave_with___finally@@"(i8 0, i8* %[[fp]])
|
2015-02-13 07:16:11 +08:00
|
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Mixed, nested cases.
|
|
|
|
|
|
|
|
int nested___except___finally() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
__try {
|
|
|
|
g();
|
|
|
|
} __finally {
|
|
|
|
g();
|
|
|
|
__leave; // Refers to the outer __try, not the __finally!
|
|
|
|
myres = 23;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
myres = 51;
|
|
|
|
} __except (1) {
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @nested___except___finally()
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK-LABEL: invoke void @g()
|
|
|
|
// CHECK-NEXT: to label %[[g1_cont1:.*]] unwind label %[[g1_lpad:.*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: [[g1_cont1]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: invoke void @"?fin$0@0@nested___except___finally@@"(i8 0, i8* %[[fp]])
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK-NEXT: to label %[[fin_cont:.*]] unwind label %[[g2_lpad:.*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: [[fin_cont]]
|
2015-02-27 06:34:33 +08:00
|
|
|
// CHECK: store i32 51, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[trycont:[^ ]*]]
|
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[g1_lpad]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK-NEXT: cleanuppad
|
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: invoke void @"?fin$0@0@nested___except___finally@@"(i8 1, i8* %[[fp]])
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK-NEXT: to label %[[g1_resume:.*]] unwind label %[[g2_lpad]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: cleanupret {{.*}} unwind label %[[g2_lpad]]
|
2015-02-26 01:44:04 +08:00
|
|
|
|
|
|
|
// CHECK: [[g2_lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: catchpad {{.*}} [i8* null]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchret
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: br label %[[trycont]]
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[trycont]]
|
|
|
|
// CHECK-NEXT: ret i32 1
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$0@0@nested___except___finally@@"(i8 %abnormal_termination, i8* %frame_pointer)
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: call void @g()
|
|
|
|
// CHECK: unreachable
|
|
|
|
|
2015-02-13 07:16:11 +08:00
|
|
|
int nested___except___except() {
|
|
|
|
int myres = 0;
|
|
|
|
__try {
|
|
|
|
__try {
|
|
|
|
g();
|
|
|
|
myres = 16;
|
|
|
|
} __except (1) {
|
|
|
|
g();
|
|
|
|
__leave; // Refers to the outer __try, not the __except we're in!
|
|
|
|
myres = 23;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
myres = 51;
|
|
|
|
} __except (1) {
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
// The order of basic blocks in the below doesn't matter.
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @nested___except___except()
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK-LABEL: invoke void @g()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: to label %[[g1_cont:.*]] unwind label %[[g1_lpad:.*]]
|
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[g1_lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: catchpad {{.*}} [i8* null]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchret {{.*}} to label %[[except:[^ ]*]]
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[except]]
|
2015-07-07 08:36:30 +08:00
|
|
|
// CHECK: invoke void @g()
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: to label %[[g2_cont:.*]] unwind label %[[g2_lpad:.*]]
|
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[g2_lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: catchpad {{.*}} [i8* null]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchret
|
2015-07-07 08:36:30 +08:00
|
|
|
// CHECK: br label %[[trycont4:[^ ]*]]
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[trycont4]]
|
|
|
|
// CHECK-NEXT: ret i32 1
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: [[g2_cont]]
|
|
|
|
// CHECK-NEXT: br label %[[tryleave:[^ ]*]]
|
|
|
|
// CHECK-NOT: store i32 23
|
|
|
|
|
|
|
|
// CHECK: [[g1_cont]]
|
|
|
|
// CHECK: store i32 16, i32* %myres
|
|
|
|
// CHECK-NEXT: br label %[[trycont:[^ ]*]]
|
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[trycont]]
|
2015-02-13 07:16:11 +08:00
|
|
|
// CHECK-NEXT: store i32 51, i32* %myres
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK-NEXT: br label %[[tryleave]]
|
2015-02-13 07:16:11 +08:00
|
|
|
|
2015-02-26 01:44:04 +08:00
|
|
|
// CHECK: [[tryleave]]
|
|
|
|
// CHECK-NEXT: br label %[[trycont4]]
|
2015-02-28 00:40:43 +08:00
|
|
|
|
|
|
|
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.
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @nested___finally___except()
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK-LABEL: invoke void @g()
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NEXT: to label %[[g1_cont:.*]] unwind label %[[g1_lpad:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[g1_lpad]]
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: catchpad
|
|
|
|
// CHECK: catchret
|
2015-07-07 08:36:30 +08:00
|
|
|
// CHECK: invoke void @g()
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NEXT: to label %[[g2_cont:.*]] unwind label %[[g2_lpad:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[g2_cont]]
|
2015-07-07 08:36:30 +08:00
|
|
|
// CHECK: br label %[[tryleave:[^ ]*]]
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NOT: 23
|
|
|
|
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: [[g1_cont]]
|
|
|
|
// CHECK-NEXT: br label %[[trycont:[^ ]*]]
|
2015-02-28 00:40:43 +08:00
|
|
|
|
|
|
|
// CHECK: [[trycont]]
|
|
|
|
// CHECK: store i32 51, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[tryleave]]
|
|
|
|
|
|
|
|
// CHECK: [[tryleave]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@nested___finally___except@@"(i8 0, i8* %[[fp]])
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NEXT: ret i32 1
|
|
|
|
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: [[g2_lpad]]
|
|
|
|
// CHECK: cleanuppad
|
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@nested___finally___except@@"(i8 1, i8* %[[fp]])
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: cleanupret {{.*}} unwind to caller
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$0@0@nested___finally___except@@"(i8 %abnormal_termination, i8* %frame_pointer)
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: ret void
|
|
|
|
|
2015-02-28 00:40:43 +08:00
|
|
|
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.
|
2018-02-24 03:30:48 +08:00
|
|
|
// CHECK-LABEL: define dso_local i32 @nested___finally___finally()
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK: invoke void @g()
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NEXT: to label %[[g1_cont:.*]] unwind label %[[g1_lpad:.*]]
|
|
|
|
|
|
|
|
// CHECK: [[g1_cont]]
|
|
|
|
// CHECK: store i32 16, i32* %[[myres:[^ ]*]],
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: invoke void @"?fin$1@0@nested___finally___finally@@"(i8 0, i8* %[[fp]])
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK-NEXT: to label %[[finally_cont:.*]] unwind label %[[g2_lpad:.*]]
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: [[finally_cont]]
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK: store i32 51, i32* %[[myres]]
|
2015-07-08 07:23:31 +08:00
|
|
|
// CHECK: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@nested___finally___finally@@"(i8 0, i8* %[[fp]])
|
2015-02-28 00:40:43 +08:00
|
|
|
// CHECK-NEXT: ret i32 1
|
|
|
|
|
|
|
|
// CHECK: [[g1_lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK-NEXT: %[[padtoken:[^ ]*]] = cleanuppad within none []
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: invoke void @"?fin$1@0@nested___finally___finally@@"(i8 1, i8* %[[fp]])
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK-NEXT: to label %[[finally_cont2:.*]] unwind label %[[g2_lpad]]
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: [[finally_cont2]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: cleanupret from %[[padtoken]] unwind label %[[g2_lpad]]
|
2015-10-08 09:13:52 +08:00
|
|
|
|
|
|
|
// CHECK: [[g2_lpad]]
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK-NEXT: %[[padtoken:[^ ]*]] = cleanuppad within none []
|
2015-10-08 09:13:52 +08:00
|
|
|
// CHECK-NEXT: %[[fp:[^ ]*]] = call i8* @llvm.localaddress()
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-NEXT: call void @"?fin$0@0@nested___finally___finally@@"(i8 1, i8* %[[fp]])
|
2015-12-12 13:39:21 +08:00
|
|
|
// CHECK: cleanupret from %[[padtoken]] unwind to caller
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$0@0@nested___finally___finally@@"(i8 %abnormal_termination, i8* %frame_pointer)
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: ret void
|
2015-02-28 00:40:43 +08:00
|
|
|
|
2018-03-17 04:36:49 +08:00
|
|
|
// CHECK-LABEL: define internal void @"?fin$1@0@nested___finally___finally@@"(i8 %abnormal_termination, i8* %frame_pointer)
|
2015-04-15 04:59:00 +08:00
|
|
|
// CHECK: call void @g()
|
|
|
|
// CHECK: unreachable
|