2015-10-08 18:41:52 +00:00
|
|
|
; RUN: llc < %s | FileCheck %s
|
|
|
|
|
|
|
|
; The aligned alloca means that we have to realign the stack, which forces the
|
|
|
|
; use of ESI to address local variables.
|
|
|
|
|
|
|
|
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
|
|
|
target triple = "i686--windows-msvc"
|
|
|
|
|
|
|
|
; Function Attrs: nounwind
|
|
|
|
define void @realigned_try() personality i8* bitcast (i32 (...)* @_except_handler3 to i8*) {
|
|
|
|
entry:
|
|
|
|
%x = alloca [4 x i32], align 16
|
|
|
|
%arrayidx = getelementptr inbounds [4 x i32], [4 x i32]* %x, i32 0, i32 0
|
|
|
|
invoke void @useit(i32* %arrayidx)
|
|
|
|
to label %__try.cont unwind label %catch.dispatch
|
|
|
|
|
|
|
|
catch.dispatch: ; 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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255422 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12 05:38:55 +00:00
|
|
|
%cs1 = catchswitch within none [label %__except.ret] unwind to caller
|
2015-10-08 18:41:52 +00:00
|
|
|
|
|
|
|
__except.ret: ; preds = %catch.dispatch
|
[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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255422 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12 05:38:55 +00:00
|
|
|
%pad = catchpad within %cs1 [i8* bitcast (i32 ()* @"\01?filt$0@0@realigned_try@@" to i8*)]
|
|
|
|
catchret from %pad to label %__try.cont
|
2015-10-08 18:41:52 +00:00
|
|
|
|
|
|
|
__try.cont: ; preds = %entry, %__except.ret
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; Function Attrs: nounwind argmemonly
|
|
|
|
|
|
|
|
; Function Attrs: nounwind
|
|
|
|
define internal i32 @"\01?filt$0@0@realigned_try@@"() {
|
|
|
|
entry:
|
|
|
|
ret i32 1
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @useit(i32*)
|
|
|
|
|
|
|
|
declare i32 @_except_handler3(...)
|
|
|
|
|
|
|
|
; CHECK-LABEL: _realigned_try:
|
|
|
|
; Prologue
|
|
|
|
; CHECK: pushl %ebp
|
|
|
|
; CHECK: movl %esp, %ebp
|
|
|
|
; CHECK: pushl %ebx
|
|
|
|
; CHECK: pushl %edi
|
|
|
|
; CHECK: pushl %esi
|
|
|
|
; CHECK: andl $-16, %esp
|
|
|
|
; CHECK: subl $64, %esp
|
|
|
|
; CHECK: movl %esp, %esi
|
|
|
|
; Spill EBP
|
|
|
|
; CHECK: movl %ebp, 12(%esi)
|
|
|
|
; Spill ESP
|
|
|
|
; CHECK: movl %esp, 36(%esi)
|
|
|
|
; The state is stored at ESI+56, the end of the node is ESI+60.
|
|
|
|
; CHECK: movl $-1, 56(%esi)
|
|
|
|
;
|
|
|
|
; __try
|
|
|
|
; CHECK: calll _useit
|
|
|
|
;
|
|
|
|
; Epilogue
|
2015-11-09 23:07:48 +00:00
|
|
|
; CHECK: LBB0_2: # %__try.cont
|
2015-10-08 18:41:52 +00:00
|
|
|
; CHECK: leal -12(%ebp), %esp
|
|
|
|
; CHECK: popl %esi
|
|
|
|
; CHECK: popl %edi
|
|
|
|
; CHECK: popl %ebx
|
|
|
|
; CHECK: popl %ebp
|
|
|
|
; 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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@255422 91177308-0d34-0410-b5e6-96231b3b80d8
2015-12-12 05:38:55 +00:00
|
|
|
; CHECK: LBB0_1: # %__except.ret
|
2015-10-08 18:41:52 +00:00
|
|
|
; Restore ESP
|
|
|
|
; CHECK: movl -24(%ebp), %esp
|
|
|
|
; Recompute ESI by subtracting 60 from the end of the registration node.
|
|
|
|
; CHECK: leal -60(%ebp), %esi
|
|
|
|
; Restore EBP
|
|
|
|
; CHECK: movl 12(%esi), %ebp
|
|
|
|
; Rejoin normal control flow
|
2015-11-09 23:07:48 +00:00
|
|
|
; CHECK: jmp LBB0_2
|