2016-02-16 07:44:13 +08:00
|
|
|
; RUN: llc -stack-symbol-ordering=0 -mtriple=i686-windows-msvc < %s | FileCheck %s
|
2015-06-12 06:32:23 +08:00
|
|
|
|
|
|
|
; 32-bit catch-all has to use a filter function because that's how it saves the
|
|
|
|
; exception code.
|
|
|
|
|
|
|
|
@str = linkonce_odr unnamed_addr constant [27 x i8] c"GetExceptionCode(): 0x%lx\0A\00", align 1
|
|
|
|
|
|
|
|
declare i32 @_except_handler3(...)
|
|
|
|
declare void @crash()
|
|
|
|
declare i32 @printf(i8* nocapture readonly, ...) nounwind
|
|
|
|
declare i32 @llvm.eh.typeid.for(i8*)
|
|
|
|
declare i8* @llvm.frameaddress(i32)
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
llvm-svn: 241633
2015-07-08 06:25:32 +08:00
|
|
|
declare i8* @llvm.localrecover(i8*, i8*, i32)
|
|
|
|
declare void @llvm.localescape(...)
|
2015-07-01 06:46:59 +08:00
|
|
|
declare i8* @llvm.x86.seh.recoverfp(i8*, i8*)
|
2015-06-12 06:32:23 +08:00
|
|
|
|
2015-06-18 04:52:32 +08:00
|
|
|
define i32 @main() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
|
2015-06-12 06:32:23 +08:00
|
|
|
entry:
|
|
|
|
%__exceptioncode = alloca i32, align 4
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
llvm-svn: 241633
2015-07-08 06:25:32 +08:00
|
|
|
call void (...) @llvm.localescape(i32* %__exceptioncode)
|
2015-06-12 06:32:23 +08:00
|
|
|
invoke void @crash() #5
|
|
|
|
to label %__try.cont unwind label %lpad
|
|
|
|
|
|
|
|
lpad: ; preds = %entry
|
[IR] Reformulate LLVM's EH funclet IR
While we have successfully implemented a funclet-oriented EH scheme on
top of LLVM IR, our scheme has some notable deficiencies:
- catchendpad and cleanupendpad are necessary in the current design
but they are difficult to explain to others, even to seasoned LLVM
experts.
- catchendpad and cleanupendpad are optimization barriers. They cannot
be split and force all potentially throwing call-sites to be invokes.
This has a noticable effect on the quality of our code generation.
- catchpad, while similar in some aspects to invoke, is fairly awkward.
It is unsplittable, starts a funclet, and has control flow to other
funclets.
- The nesting relationship between funclets is currently a property of
control flow edges. Because of this, we are forced to carefully
analyze the flow graph to see if there might potentially exist illegal
nesting among funclets. While we have logic to clone funclets when
they are illegally nested, it would be nicer if we had a
representation which forbade them upfront.
Let's clean this up a bit by doing the following:
- Instead, make catchpad more like cleanuppad and landingpad: no control
flow, just a bunch of simple operands; catchpad would be splittable.
- Introduce catchswitch, a control flow instruction designed to model
the constraints of funclet oriented EH.
- Make funclet scoping explicit by having funclet instructions consume
the token produced by the funclet which contains them.
- Remove catchendpad and cleanupendpad. Their presence can be inferred
implicitly using coloring information.
N.B. The state numbering code for the CLR has been updated but the
veracity of it's output cannot be spoken for. An expert should take a
look to make sure the results are reasonable.
Reviewers: rnk, JosephTremoulet, andrew.w.kaylor
Differential Revision: http://reviews.llvm.org/D15139
llvm-svn: 255422
2015-12-12 13:38:55 +08:00
|
|
|
%cs1 = catchswitch within none [label %__except] unwind to caller
|
2015-06-12 06:32:23 +08:00
|
|
|
|
|
|
|
__except: ; preds = %lpad
|
[IR] Reformulate LLVM's EH funclet IR
While we have successfully implemented a funclet-oriented EH scheme on
top of LLVM IR, our scheme has some notable deficiencies:
- catchendpad and cleanupendpad are necessary in the current design
but they are difficult to explain to others, even to seasoned LLVM
experts.
- catchendpad and cleanupendpad are optimization barriers. They cannot
be split and force all potentially throwing call-sites to be invokes.
This has a noticable effect on the quality of our code generation.
- catchpad, while similar in some aspects to invoke, is fairly awkward.
It is unsplittable, starts a funclet, and has control flow to other
funclets.
- The nesting relationship between funclets is currently a property of
control flow edges. Because of this, we are forced to carefully
analyze the flow graph to see if there might potentially exist illegal
nesting among funclets. While we have logic to clone funclets when
they are illegally nested, it would be nicer if we had a
representation which forbade them upfront.
Let's clean this up a bit by doing the following:
- Instead, make catchpad more like cleanuppad and landingpad: no control
flow, just a bunch of simple operands; catchpad would be splittable.
- Introduce catchswitch, a control flow instruction designed to model
the constraints of funclet oriented EH.
- Make funclet scoping explicit by having funclet instructions consume
the token produced by the funclet which contains them.
- Remove catchendpad and cleanupendpad. Their presence can be inferred
implicitly using coloring information.
N.B. The state numbering code for the CLR has been updated but the
veracity of it's output cannot be spoken for. An expert should take a
look to make sure the results are reasonable.
Reviewers: rnk, JosephTremoulet, andrew.w.kaylor
Differential Revision: http://reviews.llvm.org/D15139
llvm-svn: 255422
2015-12-12 13:38:55 +08:00
|
|
|
%p = catchpad within %cs1 [i8* bitcast (i32 ()* @"filt$main" to i8*)]
|
2015-10-10 07:05:54 +08:00
|
|
|
%code = load i32, i32* %__exceptioncode, align 4
|
2015-12-16 05:27:27 +08:00
|
|
|
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i32 0, i32 0), i32 %code) #4 [ "funclet"(token %p) ]
|
[IR] Reformulate LLVM's EH funclet IR
While we have successfully implemented a funclet-oriented EH scheme on
top of LLVM IR, our scheme has some notable deficiencies:
- catchendpad and cleanupendpad are necessary in the current design
but they are difficult to explain to others, even to seasoned LLVM
experts.
- catchendpad and cleanupendpad are optimization barriers. They cannot
be split and force all potentially throwing call-sites to be invokes.
This has a noticable effect on the quality of our code generation.
- catchpad, while similar in some aspects to invoke, is fairly awkward.
It is unsplittable, starts a funclet, and has control flow to other
funclets.
- The nesting relationship between funclets is currently a property of
control flow edges. Because of this, we are forced to carefully
analyze the flow graph to see if there might potentially exist illegal
nesting among funclets. While we have logic to clone funclets when
they are illegally nested, it would be nicer if we had a
representation which forbade them upfront.
Let's clean this up a bit by doing the following:
- Instead, make catchpad more like cleanuppad and landingpad: no control
flow, just a bunch of simple operands; catchpad would be splittable.
- Introduce catchswitch, a control flow instruction designed to model
the constraints of funclet oriented EH.
- Make funclet scoping explicit by having funclet instructions consume
the token produced by the funclet which contains them.
- Remove catchendpad and cleanupendpad. Their presence can be inferred
implicitly using coloring information.
N.B. The state numbering code for the CLR has been updated but the
veracity of it's output cannot be spoken for. An expert should take a
look to make sure the results are reasonable.
Reviewers: rnk, JosephTremoulet, andrew.w.kaylor
Differential Revision: http://reviews.llvm.org/D15139
llvm-svn: 255422
2015-12-12 13:38:55 +08:00
|
|
|
catchret from %p to label %__try.cont
|
2015-06-12 06:32:23 +08:00
|
|
|
|
|
|
|
__try.cont: ; preds = %entry, %__except
|
|
|
|
ret i32 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define internal i32 @"filt$main"() {
|
|
|
|
entry:
|
2015-07-01 06:46:59 +08:00
|
|
|
%ebp = tail call i8* @llvm.frameaddress(i32 1)
|
|
|
|
%parentfp = tail call i8* @llvm.x86.seh.recoverfp(i8* bitcast (i32 ()* @main to i8*), i8* %ebp)
|
Rename llvm.frameescape and llvm.framerecover to localescape and localrecover
Summary:
Initially, these intrinsics seemed like part of a family of "frame"
related intrinsics, but now I think that's more confusing than helpful.
Initially, the LangRef specified that this would create a new kind of
allocation that would be allocated at a fixed offset from the frame
pointer (EBP/RBP). We ended up dropping that design, and leaving the
stack frame layout alone.
These intrinsics are really about sharing local stack allocations, not
frame pointers. I intend to go further and add an `llvm.localaddress()`
intrinsic that returns whatever register (EBP, ESI, ESP, RBX) is being
used to address locals, which should not be confused with the frame
pointer.
Naming suggestions at this point are welcome, I'm happy to re-run sed.
Reviewers: majnemer, nicholas
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D11011
llvm-svn: 241633
2015-07-08 06:25:32 +08:00
|
|
|
%code.i8 = tail call i8* @llvm.localrecover(i8* bitcast (i32 ()* @main to i8*), i8* %parentfp, i32 0)
|
2015-07-01 06:46:59 +08:00
|
|
|
%__exceptioncode = bitcast i8* %code.i8 to i32*
|
|
|
|
%info.addr = getelementptr inbounds i8, i8* %ebp, i32 -20
|
|
|
|
%0 = bitcast i8* %info.addr to i32***
|
|
|
|
%1 = load i32**, i32*** %0, align 4
|
|
|
|
%2 = load i32*, i32** %1, align 4
|
|
|
|
%3 = load i32, i32* %2, align 4
|
|
|
|
store i32 %3, i32* %__exceptioncode, align 4
|
2015-06-12 06:32:23 +08:00
|
|
|
ret i32 1
|
|
|
|
}
|
|
|
|
|
|
|
|
; Check that we can get the exception code from eax to the printf.
|
|
|
|
|
|
|
|
; CHECK-LABEL: _main:
|
2015-07-10 06:09:41 +08:00
|
|
|
; CHECK: pushl %ebp
|
|
|
|
; CHECK: movl %esp, %ebp
|
|
|
|
; Ensure that we push *all* the CSRs, since they are clobbered by the
|
|
|
|
; __except block.
|
|
|
|
; CHECK: pushl %ebx
|
|
|
|
; CHECK: pushl %edi
|
|
|
|
; CHECK: pushl %esi
|
|
|
|
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: Lmain$frame_escape_0 = [[code_offs:[-0-9]+]]
|
2015-11-18 05:10:25 +08:00
|
|
|
; CHECK: movl %esp, [[reg_offs:[-0-9]+]](%ebp)
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: movl $L__ehtable$main,
|
2015-10-10 07:05:54 +08:00
|
|
|
; EH state 0
|
2015-07-10 06:09:41 +08:00
|
|
|
; CHECK: movl $0, -16(%ebp)
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: calll _crash
|
2015-07-10 06:09:41 +08:00
|
|
|
; CHECK: popl %esi
|
|
|
|
; CHECK: popl %edi
|
|
|
|
; CHECK: popl %ebx
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: retl
|
[IR] Reformulate LLVM's EH funclet IR
While we have successfully implemented a funclet-oriented EH scheme on
top of LLVM IR, our scheme has some notable deficiencies:
- catchendpad and cleanupendpad are necessary in the current design
but they are difficult to explain to others, even to seasoned LLVM
experts.
- catchendpad and cleanupendpad are optimization barriers. They cannot
be split and force all potentially throwing call-sites to be invokes.
This has a noticable effect on the quality of our code generation.
- catchpad, while similar in some aspects to invoke, is fairly awkward.
It is unsplittable, starts a funclet, and has control flow to other
funclets.
- The nesting relationship between funclets is currently a property of
control flow edges. Because of this, we are forced to carefully
analyze the flow graph to see if there might potentially exist illegal
nesting among funclets. While we have logic to clone funclets when
they are illegally nested, it would be nicer if we had a
representation which forbade them upfront.
Let's clean this up a bit by doing the following:
- Instead, make catchpad more like cleanuppad and landingpad: no control
flow, just a bunch of simple operands; catchpad would be splittable.
- Introduce catchswitch, a control flow instruction designed to model
the constraints of funclet oriented EH.
- Make funclet scoping explicit by having funclet instructions consume
the token produced by the funclet which contains them.
- Remove catchendpad and cleanupendpad. Their presence can be inferred
implicitly using coloring information.
N.B. The state numbering code for the CLR has been updated but the
veracity of it's output cannot be spoken for. An expert should take a
look to make sure the results are reasonable.
Reviewers: rnk, JosephTremoulet, andrew.w.kaylor
Differential Revision: http://reviews.llvm.org/D15139
llvm-svn: 255422
2015-12-12 13:38:55 +08:00
|
|
|
; CHECK: LBB0_[[lpbb:[0-9]+]]: # %__except{{$}}
|
2015-10-10 07:05:54 +08:00
|
|
|
; stackrestore
|
2015-07-10 06:09:41 +08:00
|
|
|
; CHECK: movl -24(%ebp), %esp
|
2015-10-10 07:05:54 +08:00
|
|
|
; EH state -1
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: movl [[code_offs]](%ebp), %[[code:[a-z]+]]
|
|
|
|
; CHECK-DAG: movl %[[code]], 4(%esp)
|
|
|
|
; CHECK-DAG: movl $_str, (%esp)
|
|
|
|
; CHECK: calll _printf
|
|
|
|
|
|
|
|
; CHECK: .section .xdata,"dr"
|
2015-11-18 05:10:25 +08:00
|
|
|
; CHECK: Lmain$parent_frame_offset = [[reg_offs]]
|
2016-01-26 08:03:25 +08:00
|
|
|
; CHECK: .p2align 2
|
2015-06-12 06:32:23 +08:00
|
|
|
; CHECK: L__ehtable$main
|
|
|
|
; CHECK-NEXT: .long -1
|
|
|
|
; CHECK-NEXT: .long _filt$main
|
2015-10-10 07:05:54 +08:00
|
|
|
; CHECK-NEXT: .long LBB0_[[lpbb]]
|
2015-06-12 06:32:23 +08:00
|
|
|
|
|
|
|
; CHECK-LABEL: _filt$main:
|
2015-07-01 06:46:59 +08:00
|
|
|
; CHECK: pushl %ebp
|
|
|
|
; CHECK: movl %esp, %ebp
|
|
|
|
; CHECK: movl (%ebp), %[[oldebp:[a-z]+]]
|
|
|
|
; CHECK: movl -20(%[[oldebp]]), %[[ehinfo:[a-z]+]]
|
|
|
|
; CHECK: movl (%[[ehinfo]]), %[[ehrec:[a-z]+]]
|
|
|
|
; CHECK: movl (%[[ehrec]]), %[[ehcode:[a-z]+]]
|
|
|
|
; CHECK: movl %[[ehcode]], {{.*}}(%{{.*}})
|