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/Transforms/LoopStrengthReduce/funclet.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/Transforms/LoopStrengthReduce/funclet.ll')
-rw-r--r-- | llvm/test/Transforms/LoopStrengthReduce/funclet.ll | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/llvm/test/Transforms/LoopStrengthReduce/funclet.ll b/llvm/test/Transforms/LoopStrengthReduce/funclet.ll index 03799ddfdb5..a2da3208a38 100644 --- a/llvm/test/Transforms/LoopStrengthReduce/funclet.ll +++ b/llvm/test/Transforms/LoopStrengthReduce/funclet.ll @@ -20,19 +20,17 @@ throw: ; preds = %throw, %entry pad: ; preds = %throw %phi2 = phi i8* [ %tmp96, %throw ] - terminatepad [] unwind label %blah + terminatepad within none [] unwind label %blah blah: - catchpad [] to label %unreachable unwind label %blah3 + %cs = catchswitch within none [label %unreachable] unwind label %blah2 unreachable: + catchpad within %cs [] unreachable -blah3: - catchendpad unwind label %blah2 - blah2: - %cleanuppadi4.i.i.i = cleanuppad [] + %cleanuppadi4.i.i.i = cleanuppad within none [] br label %loop_body loop_body: ; preds = %iter, %pad @@ -45,11 +43,11 @@ iter: ; preds = %loop_body br i1 undef, label %unwind_out, label %loop_body unwind_out: ; preds = %iter, %loop_body - cleanupret %cleanuppadi4.i.i.i unwind to caller + cleanupret from %cleanuppadi4.i.i.i unwind to caller } ; CHECK-LABEL: define void @f( -; CHECK: cleanuppad [] +; CHECK: cleanuppad within none [] ; CHECK-NEXT: ptrtoint i8* %phi2 to i32 define void @g() personality i32 (...)* @_except_handler3 { @@ -63,20 +61,18 @@ throw: ; preds = %throw, %entry pad: %phi2 = phi i8* [ %tmp96, %throw ] - catchpad [] to label %unreachable unwind label %blah + %cs = catchswitch within none [label %unreachable, label %blah] unwind to caller unreachable: + catchpad within %cs [] unreachable blah: - %catchpad = catchpad [] to label %loop_body unwind label %blah3 - - -blah3: - catchendpad unwind to caller ;label %blah2 + %catchpad = catchpad within %cs [] + br label %loop_body unwind_out: - catchret %catchpad to label %leave + catchret from %catchpad to label %leave leave: ret void @@ -93,10 +89,7 @@ iter: ; preds = %loop_body ; CHECK-LABEL: define void @g( ; CHECK: blah: -; CHECK-NEXT: catchpad [] -; CHECK-NEXT: to label %loop_body.preheader - -; CHECK: loop_body.preheader: +; CHECK-NEXT: catchpad within %cs [] ; CHECK-NEXT: ptrtoint i8* %phi2 to i32 @@ -110,29 +103,25 @@ throw: ; preds = %throw, %entry to label %throw unwind label %pad pad: - catchpad [] to label %unreachable unwind label %blug + %cs = catchswitch within none [label %unreachable, label %blug] unwind to caller unreachable: + catchpad within %cs [] unreachable blug: %phi2 = phi i8* [ %tmp96, %pad ] - %catchpad = catchpad [] to label %blah2 unwind label %blah3 - -blah2: + %catchpad = catchpad within %cs [] br label %loop_body -blah3: - catchendpad unwind to caller ;label %blah2 - unwind_out: - catchret %catchpad to label %leave + catchret from %catchpad to label %leave leave: ret void loop_body: ; preds = %iter, %pad - %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blah2 ] + %tmp99 = phi i8* [ %tmp101, %iter ], [ %phi2, %blug ] %tmp100 = icmp eq i8* %tmp99, undef br i1 %tmp100, label %unwind_out, label %iter @@ -143,10 +132,7 @@ iter: ; preds = %loop_body ; CHECK-LABEL: define void @h( ; CHECK: blug: -; CHECK: catchpad [] -; CHECK-NEXT: to label %blah2 - -; CHECK: blah2: +; CHECK: catchpad within %cs [] ; CHECK-NEXT: ptrtoint i8* %phi2 to i32 define void @i() personality i32 (...)* @_except_handler3 { @@ -160,16 +146,14 @@ throw: ; preds = %throw, %entry catchpad: ; preds = %throw %phi2 = phi i8* [ %tmp96, %throw ] - catchpad [] to label %cp_body unwind label %catchendpad + %cs = catchswitch within none [label %cp_body] unwind label %cleanuppad cp_body: + catchpad within %cs [] br label %loop_head -catchendpad: - catchendpad unwind label %cleanuppad - cleanuppad: - cleanuppad [] + cleanuppad within none [] br label %loop_head loop_head: @@ -205,39 +189,31 @@ for.inc: ; preds = %for.cond br label %for.cond catch.dispatch: ; preds = %for.cond - %0 = catchpad [i8* null, i32 64, i8* null] - to label %catch unwind label %catchendblock - -catchendblock: ; preds = %catch.dispatch - catchendpad unwind label %catch.dispatch.2 + %cs = catchswitch within none [label %catch] unwind label %catch.dispatch.2 catch: ; preds = %catch.dispatch - catchret %0 to label %try.cont + %0 = catchpad within %cs [i8* null, i32 64, i8* null] + catchret from %0 to label %try.cont try.cont: ; preds = %catch invoke void @external(i32* %c) to label %try.cont.7 unwind label %catch.dispatch.2 catch.dispatch.2: ; preds = %try.cont, %catchendblock - %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ] - %1 = catchpad [i8* null, i32 64, i8* null] - to label %catch.4 unwind label %catchendblock.3 + %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catch.dispatch ] + %cs2 = catchswitch within none [label %catch.4] unwind to caller catch.4: ; preds = %catch.dispatch.2 + catchpad within %cs2 [i8* null, i32 64, i8* null] unreachable try.cont.7: ; preds = %try.cont ret void - -catchendblock.3: ; preds = %catch.dispatch.2 - catchendpad unwind to caller } ; CHECK-LABEL: define void @test1( ; CHECK: for.cond: ; CHECK: %d.0 = phi i32* [ %b, %entry ], [ %incdec.ptr, %for.inc ] -; CHECK: catchendpad unwind label %catch.dispatch.2 - ; CHECK: catch.dispatch.2: -; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catchendblock ] +; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catch.dispatch ] |