diff options
author | David Majnemer <david.majnemer@gmail.com> | 2015-12-12 05:38:55 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2015-12-12 05:38:55 +0000 |
commit | 8a1c45d6e86d54c40835fa8638d1fd900071783c (patch) | |
tree | e485010342db16bc7c4de112e89d5b5e23b29bba /llvm/test/CodeGen/X86/funclet-layout.ll | |
parent | a38312a9a4eeb8ab8976adf5712fadd68dd763cf (diff) | |
download | bcm5719-llvm-8a1c45d6e86d54c40835fa8638d1fd900071783c.tar.gz bcm5719-llvm-8a1c45d6e86d54c40835fa8638d1fd900071783c.zip |
[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
Diffstat (limited to 'llvm/test/CodeGen/X86/funclet-layout.ll')
-rw-r--r-- | llvm/test/CodeGen/X86/funclet-layout.ll | 69 |
1 files changed, 31 insertions, 38 deletions
diff --git a/llvm/test/CodeGen/X86/funclet-layout.ll b/llvm/test/CodeGen/X86/funclet-layout.ll index 053d484889b..b5972df43cc 100644 --- a/llvm/test/CodeGen/X86/funclet-layout.ll +++ b/llvm/test/CodeGen/X86/funclet-layout.ll @@ -15,21 +15,21 @@ entry: to label %unreachable unwind label %catch.dispatch catch.dispatch: - %cp = catchpad [i8* null, i32 64, i8* null] - to label %catch unwind label %catchendblock + %cs1 = catchswitch within none [label %catch] unwind to caller catch: - br i1 %B, label %catchret, label %catch + %cp = catchpad within %cs1 [i8* null, i32 64, i8* null] + br label %catch.loop + +catch.loop: + br i1 %B, label %catchret, label %catch.loop catchret: - catchret %cp to label %try.cont + catchret from %cp to label %try.cont try.cont: ret void -catchendblock: - catchendpad unwind to caller - unreachable: unreachable } @@ -55,54 +55,50 @@ entry: to label %unreachable unwind label %catch.dispatch catch.dispatch: ; preds = %entry - %0 = catchpad [i8* null, i32 64, i8* null] - to label %catch unwind label %catchendblock + %cs1 = catchswitch within none [label %catch] unwind to caller catch: ; preds = %catch.dispatch + %0 = catchpad within %cs1 [i8* null, i32 64, i8* null] invoke void @_CxxThrowException(i8* null, %eh.ThrowInfo* null) #1 to label %unreachable unwind label %catch.dispatch.1 catch.dispatch.1: ; preds = %catch - %1 = catchpad [i8* null, i32 64, i8* null] - to label %catch.3 unwind label %catchendblock.2 + %cs2 = catchswitch within %0 [label %catch.3] unwind to caller catch.3: ; preds = %catch.dispatch.1 - catchret %1 to label %try.cont + %1 = catchpad within %cs2 [i8* null, i32 64, i8* null] + catchret from %1 to label %try.cont try.cont: ; preds = %catch.3 - catchret %0 to label %try.cont.5 + catchret from %0 to label %try.cont.5 try.cont.5: ; preds = %try.cont ret i32 0 -catchendblock.2: ; preds = %catch.dispatch.1 - catchendpad unwind label %catchendblock - -catchendblock: ; preds = %catchendblock.2, %catch.dispatch - catchendpad unwind to caller - unreachable: ; preds = %catch, %entry unreachable - } ; CHECK-LABEL: test2: -; The entry funclet contains %entry and %try.cont.5 +; The parent function contains %entry and %try.cont.5 +; CHECK: .seh_proc ; CHECK: # %entry ; CHECK: # %try.cont.5 ; CHECK: retq -; The outer catch funclet contains %catch.dispatch -; CHECK: # %catch.dispatch{{$}} +; The inner catch funclet contains %catch.3 +; CHECK: .seh_proc +; CHECK: # %catch.3{{$}} +; CHECK: retq + +; The outer catch funclet contains %catch +; CHECK: .seh_proc +; CHECK: # %catch{{$}} ; CHECK: callq _CxxThrowException ; CHECK: # %unreachable ; CHECK: ud2 -; The inner catch funclet contains %catch.dispatch.1 -; CHECK: # %catch.dispatch.1 -; CHECK: retq - define void @test3(i1 %V) #0 personality i8* bitcast (i32 (...)* @__CxxFrameHandler3 to i8*) { entry: @@ -110,24 +106,21 @@ entry: to label %try.cont unwind label %catch.dispatch catch.dispatch: ; preds = %entry - %0 = catchpad [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null] - to label %catch.2 unwind label %catch.dispatch.1 + %cs1 = catchswitch within none [label %catch.2] unwind label %catch.dispatch.1 catch.2: ; preds = %catch.dispatch + %0 = catchpad within %cs1 [%rtti.TypeDescriptor2* @"\01??_R0H@8", i32 0, i8* null] tail call void @exit(i32 0) #2 unreachable catch.dispatch.1: ; preds = %catch.dispatch - %1 = catchpad [i8* null, i32 64, i8* null] - to label %catch unwind label %catchendblock + %cs2 = catchswitch within none [label %catch] unwind to caller catch: ; preds = %catch.dispatch.1 + %1 = catchpad within %cs2 [i8* null, i32 64, i8* null] tail call void @exit(i32 0) #2 unreachable -catchendblock: ; preds = %catch.dispatch.1 - catchendpad unwind to caller - try.cont: ; preds = %entry br i1 %V, label %exit_one, label %exit_two @@ -150,13 +143,13 @@ exit_two: ; CHECK-NOT: # exit_two ; CHECK: ud2 -; The catch(...) funclet contains %catch.dispatch -; CHECK: # %catch.dispatch{{$}} +; The catch(...) funclet contains %catch.2 +; CHECK: # %catch.2{{$}} ; CHECK: callq exit ; CHECK: ud2 -; The catch(int) funclet contains %catch.dispatch.1 -; CHECK: # %catch.dispatch.1 +; The catch(int) funclet contains %catch +; CHECK: # %catch{{$}} ; CHECK: callq exit ; CHECK: ud2 |