2015-02-06 02:56:03 +08:00
|
|
|
// RUN: %clang_cc1 %s -triple x86_64-pc-win32 -fms-extensions -emit-llvm -o - | 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-02-05 08:58:46 +08:00
|
|
|
void abort(void) __attribute__((noreturn));
|
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
|
|
|
void might_crash(void);
|
|
|
|
void cleanup(void);
|
|
|
|
int check_condition(void);
|
|
|
|
void basic_finally(void) {
|
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @basic_finally()
|
|
|
|
// CHECK: invoke void @might_crash()
|
2015-02-05 06:37:07 +08:00
|
|
|
// CHECK: to label %[[invoke_cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[invoke_cont]]
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %[[abnormal:[^ ]*]]
|
|
|
|
// CHECK: br label %[[finally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK: call void @cleanup()
|
|
|
|
// CHECK: load i8, i8* %[[abnormal]]
|
|
|
|
// CHECK: icmp eq
|
|
|
|
// CHECK: br i1 %{{.*}}, label %[[finallycont:[^ ]*]], label %[[resumecont:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallycont]]
|
2015-02-05 06:37:07 +08:00
|
|
|
// CHECK-NEXT: ret void
|
|
|
|
//
|
|
|
|
// CHECK: [[lpad]]
|
|
|
|
// CHECK-NEXT: landingpad
|
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
|
|
|
// CHECK-NEXT: cleanup
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 1, i8* %[[abnormal]]
|
|
|
|
// CHECK: br label %[[finally]]
|
|
|
|
//
|
|
|
|
// CHECK: [[resumecont]]
|
|
|
|
// CHECK: br label %[[ehresume:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[ehresume]]
|
2015-02-05 06:37:07 +08:00
|
|
|
// CHECK: resume { i8*, i32 }
|
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-05 06:37:07 +08:00
|
|
|
// Mostly check that we don't double emit 'r' which would crash.
|
|
|
|
void decl_in_finally(void) {
|
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
int r;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ditto, don't crash double emitting 'l'.
|
|
|
|
void label_in_finally(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
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
l:
|
|
|
|
cleanup();
|
|
|
|
if (check_condition())
|
|
|
|
goto l;
|
|
|
|
}
|
|
|
|
}
|
2015-02-05 06:37:07 +08:00
|
|
|
|
|
|
|
// CHECK-LABEL: define void @label_in_finally()
|
|
|
|
// CHECK: invoke void @might_crash()
|
|
|
|
// CHECK: to label %[[invoke_cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[invoke_cont]]
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %[[abnormal:[^ ]*]]
|
|
|
|
// CHECK: br label %[[finally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finally]]
|
2015-02-05 06:37:07 +08:00
|
|
|
// CHECK: br label %[[l:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[l]]
|
|
|
|
// CHECK: call void @cleanup()
|
|
|
|
// CHECK: call i32 @check_condition()
|
|
|
|
// CHECK: br i1 {{.*}}, label
|
|
|
|
// CHECK: br label %[[l]]
|
|
|
|
|
|
|
|
int crashed;
|
|
|
|
void use_abnormal_termination(void) {
|
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
crashed = __abnormal_termination();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @use_abnormal_termination()
|
|
|
|
// CHECK: invoke void @might_crash()
|
|
|
|
// CHECK: to label %[[invoke_cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[invoke_cont]]
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %[[abnormal:[^ ]*]]
|
|
|
|
// CHECK: br label %[[finally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK: load i8, i8* %[[abnormal]]
|
|
|
|
// CHECK: zext i8 %{{.*}} to i32
|
|
|
|
// CHECK: store i32 %{{.*}}, i32* @crashed
|
|
|
|
// CHECK: load i8, i8* %[[abnormal]]
|
|
|
|
// CHECK: icmp eq
|
|
|
|
// CHECK: br i1 %{{.*}}, label %[[finallycont:[^ ]*]], label %[[resumecont:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallycont]]
|
|
|
|
// CHECK-NEXT: ret void
|
2015-02-05 06:37:07 +08:00
|
|
|
//
|
|
|
|
// CHECK: [[lpad]]
|
|
|
|
// CHECK-NEXT: landingpad
|
|
|
|
// CHECK-NEXT: cleanup
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 1, i8* %[[abnormal]]
|
|
|
|
// CHECK: br label %[[finally]]
|
|
|
|
//
|
|
|
|
// CHECK: [[resumecont]]
|
|
|
|
// CHECK: br label %[[ehresume:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[ehresume]]
|
2015-02-05 06:37:07 +08:00
|
|
|
// CHECK: resume { i8*, i32 }
|
2015-02-05 08:58:46 +08:00
|
|
|
|
|
|
|
void noreturn_noop_finally() {
|
|
|
|
__try {
|
|
|
|
__noop();
|
|
|
|
} __finally {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @noreturn_noop_finally()
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %
|
|
|
|
// CHECK: br label %[[finally:[^ ]*]]
|
|
|
|
// CHECK: [[finally]]
|
2015-02-05 08:58:46 +08:00
|
|
|
// CHECK: call void @abort()
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
// CHECK-NOT: load
|
2015-02-05 08:58:46 +08:00
|
|
|
|
|
|
|
void noreturn_finally() {
|
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
abort();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK-LABEL: define void @noreturn_finally()
|
|
|
|
// CHECK: invoke void @might_crash()
|
|
|
|
// CHECK: to label %[[cont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[cont]]
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %
|
|
|
|
// CHECK: br label %[[finally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK: call void @abort()
|
|
|
|
// CHECK-NEXT: unreachable
|
2015-02-05 08:58:46 +08:00
|
|
|
//
|
|
|
|
// CHECK: [[lpad]]
|
|
|
|
// CHECK: landingpad
|
|
|
|
// CHECK-NEXT: cleanup
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 1, i8* %
|
|
|
|
// CHECK: br label %[[finally]]
|
Reland r230460 with a test fix for -Asserts builds.
Original CL description:
Produce less broken basic block sequences for __finally blocks.
The way cleanups (such as PerformSEHFinally) get emitted is that codegen
generates some initialization code, then calls the cleanup's Emit() with the
insertion point set to a good place, then the cleanup is supposed to emit its
stuff, and then codegen might tack in a jump or similar to where the insertion
point is after the cleanup.
The PerformSEHFinally cleanup tries to just stash away the block it's supposed
to codegen into, and then does codegen later, into that stashed block. However,
after codegen'ing the __finally block, it used to set the insertion point to
the finally's continuation block (where the __finally cleanup goes when its body
is completed after regular, non-exceptional control flow). That's not correct,
as that block can (and generally does) already ends in a jump. Instead,
remember the insertion point that was current before the __finally got emitted,
and restore that.
Fixes two of the crashes in PR22553.
llvm-svn: 230503
2015-02-26 00:25:00 +08:00
|
|
|
|
|
|
|
int finally_with_return() {
|
|
|
|
__try {
|
|
|
|
return 42;
|
|
|
|
} __finally {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: define i32 @finally_with_return()
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %
|
|
|
|
// CHECK-NEXT: br label %[[finally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK-NEXT: br label %[[finallycont:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallycont]]
|
Reland r230460 with a test fix for -Asserts builds.
Original CL description:
Produce less broken basic block sequences for __finally blocks.
The way cleanups (such as PerformSEHFinally) get emitted is that codegen
generates some initialization code, then calls the cleanup's Emit() with the
insertion point set to a good place, then the cleanup is supposed to emit its
stuff, and then codegen might tack in a jump or similar to where the insertion
point is after the cleanup.
The PerformSEHFinally cleanup tries to just stash away the block it's supposed
to codegen into, and then does codegen later, into that stashed block. However,
after codegen'ing the __finally block, it used to set the insertion point to
the finally's continuation block (where the __finally cleanup goes when its body
is completed after regular, non-exceptional control flow). That's not correct,
as that block can (and generally does) already ends in a jump. Instead,
remember the insertion point that was current before the __finally got emitted,
and restore that.
Fixes two of the crashes in PR22553.
llvm-svn: 230503
2015-02-26 00:25:00 +08:00
|
|
|
// CHECK-NEXT: ret i32 42
|
|
|
|
|
|
|
|
int nested___finally___finally() {
|
|
|
|
__try {
|
|
|
|
__try {
|
|
|
|
} __finally {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} __finally {
|
|
|
|
// Intentionally no return here.
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: define i32 @nested___finally___finally
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 0, i8* %
|
|
|
|
// CHECK-NEXT: br label %[[finally:[^ ]*]]
|
Reland r230460 with a test fix for -Asserts builds.
Original CL description:
Produce less broken basic block sequences for __finally blocks.
The way cleanups (such as PerformSEHFinally) get emitted is that codegen
generates some initialization code, then calls the cleanup's Emit() with the
insertion point set to a good place, then the cleanup is supposed to emit its
stuff, and then codegen might tack in a jump or similar to where the insertion
point is after the cleanup.
The PerformSEHFinally cleanup tries to just stash away the block it's supposed
to codegen into, and then does codegen later, into that stashed block. However,
after codegen'ing the __finally block, it used to set the insertion point to
the finally's continuation block (where the __finally cleanup goes when its body
is completed after regular, non-exceptional control flow). That's not correct,
as that block can (and generally does) already ends in a jump. Instead,
remember the insertion point that was current before the __finally got emitted,
and restore that.
Fixes two of the crashes in PR22553.
llvm-svn: 230503
2015-02-26 00:25:00 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK-NEXT: store i32 1, i32* %
|
|
|
|
// CHECK-NEXT: store i32 1, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[cleanup:[^ ]*]]
|
2015-02-27 06:34:33 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// The finally's unreachable continuation block:
|
|
|
|
// CHECK: store i32 0, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[cleanup]]
|
|
|
|
//
|
|
|
|
// CHECK: [[cleanup]]
|
|
|
|
// CHECK-NEXT: store i8 0, i8* %
|
|
|
|
// CHECK-NEXT: br label %[[outerfinally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[outerfinally]]
|
|
|
|
// CHECK-NEXT: br label %[[finallycont:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallycont]]
|
|
|
|
// CHECK-NEXT: %[[dest:[^ ]*]] = load i32, i32* %
|
|
|
|
// CHECK-NEXT: switch i32 %[[dest]]
|
|
|
|
// CHECK-NEXT: i32 0, label %[[cleanupcont:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[cleanupcont]]
|
|
|
|
// CHECK-NEXT: store i32 0, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[return:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[return]]
|
|
|
|
// CHECK-NEXT: %[[reg:[^ ]*]] = load i32, i32* %
|
|
|
|
// CHECK-NEXT: ret i32 %[[reg]]
|
2015-02-27 06:34:33 +08:00
|
|
|
|
|
|
|
int nested___finally___finally_with_eh_edge() {
|
|
|
|
__try {
|
|
|
|
__try {
|
|
|
|
might_crash();
|
|
|
|
} __finally {
|
|
|
|
return 899;
|
|
|
|
}
|
|
|
|
} __finally {
|
|
|
|
// Intentionally no return here.
|
|
|
|
}
|
|
|
|
return 912;
|
|
|
|
}
|
|
|
|
// CHECK-LABEL: define i32 @nested___finally___finally_with_eh_edge
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: invoke void @might_crash() #3
|
|
|
|
// CHECK-NEXT: to label %[[invokecont:[^ ]*]] unwind label %[[lpad:[^ ]*]]
|
2015-04-10 12:33:03 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: [[invokecont]]
|
|
|
|
// CHECK-NEXT: store i8 0, i8* %[[abnormal:[^ ]*]]
|
|
|
|
// CHECK-NEXT: br label %[[finally:[^ ]*]]
|
|
|
|
|
|
|
|
// CHECK: [[finally]]
|
|
|
|
// CHECK-NEXT: store i32 899, i32* %
|
|
|
|
// CHECK-NEXT: store i32 1, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[cleanup:[^ ]*]]
|
2015-04-14 04:01:20 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// The inner finally's unreachable continuation block:
|
|
|
|
// CHECK: store i32 0, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[cleanup]]
|
2015-04-14 04:01:20 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: [[cleanup]]
|
|
|
|
// CHECK-NEXT: store i8 0, i8* %
|
|
|
|
// CHECK-NEXT: br label %[[outerfinally:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[outerfinally]]
|
|
|
|
// CHECK-NEXT: %[[abnormallocal:[^ ]*]] = load i8, i8* %[[abnormal]]
|
|
|
|
// CHECK-NEXT: %[[reg:[^ ]*]] = icmp eq i8 %[[abnormallocal]], 0
|
|
|
|
// CHECK-NEXT: br i1 %[[reg]], label %[[finallycont:[^ ]*]], label %[[finallyresume:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallycont]]
|
|
|
|
// CHECK-NEXT: %[[dest:[^ ]*]] = load i32, i32* %
|
|
|
|
// CHECK-NEXT: switch i32 %[[dest]]
|
|
|
|
// CHECK-NEXT: i32 0, label %[[cleanupcont:[^ ]*]]
|
2015-04-14 04:01:20 +08:00
|
|
|
//
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: [[cleanupcont]]
|
|
|
|
// CHECK-NEXT: store i32 912, i32* %
|
|
|
|
// CHECK-NEXT: br label %[[return:[^ ]*]]
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// CHECK: [[lpad]]
|
2015-04-14 04:03:03 +08:00
|
|
|
// CHECK-NEXT: landingpad
|
|
|
|
// CHECK-NEXT: cleanup
|
2015-04-14 04:04:22 +08:00
|
|
|
// CHECK: store i8 1, i8* %[[abnormal]]
|
|
|
|
// CHECK: br label %[[finally]]
|
|
|
|
//
|
|
|
|
// The inner finally's unreachable resume block:
|
|
|
|
// CHECK: store i8 1, i8* %[[abnormal]]
|
|
|
|
// CHECK-NEXT: br label %[[outerfinally]]
|
|
|
|
//
|
|
|
|
// CHECK: [[finallyresume]]
|
|
|
|
// CHECK-NEXT: br label %[[ehresume:[^ ]*]]
|
|
|
|
//
|
|
|
|
// CHECK: [[return]]
|
|
|
|
// CHECK-NEXT: %[[reg:[^ ]*]] = load i32, i32* %
|
|
|
|
// CHECK-NEXT: ret i32 %[[reg]]
|
|
|
|
//
|
|
|
|
// The ehresume block, not reachable either.
|
|
|
|
// CHECK: [[ehresume]]
|
2015-02-27 06:34:33 +08:00
|
|
|
// CHECK: resume
|