mirror of
https://github.com/RPCS3/llvm.git
synced 2026-07-19 15:13:49 -04:00
[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
This commit is contained in:
@@ -769,95 +769,91 @@ define i32 @instructions.win_eh.1() personality i32 -3 {
|
||||
entry:
|
||||
%arg1 = alloca i32
|
||||
%arg2 = alloca i32
|
||||
invoke void @f.ccc() to label %normal unwind label %catchpad1
|
||||
invoke void @f.ccc() to label %normal unwind label %catchpad2
|
||||
invoke void @f.ccc() to label %normal unwind label %catchpad3
|
||||
invoke void @f.ccc() to label %normal unwind label %catchswitch1
|
||||
invoke void @f.ccc() to label %normal unwind label %catchswitch2
|
||||
invoke void @f.ccc() to label %normal unwind label %catchswitch3
|
||||
|
||||
catchswitch1:
|
||||
%cs1 = catchswitch within none [label %catchpad1] unwind label %terminate.1
|
||||
|
||||
catchpad1:
|
||||
catchpad [] to label %normal unwind label %exn.1
|
||||
; CHECK: catchpad []
|
||||
; CHECK-NEXT: to label %normal unwind label %exn.1
|
||||
catchpad within %cs1 []
|
||||
br label %normal
|
||||
; CHECK: catchpad within %cs1 []
|
||||
; CHECK-NEXT: br label %normal
|
||||
|
||||
catchswitch2:
|
||||
%cs2 = catchswitch within none [label %catchpad2] unwind to caller
|
||||
|
||||
catchpad2:
|
||||
catchpad [i32* %arg1] to label %normal unwind label %exn.2
|
||||
; CHECK: catchpad [i32* %arg1]
|
||||
; CHECK-NEXT: to label %normal unwind label %exn.2
|
||||
catchpad within %cs2 [i32* %arg1]
|
||||
br label %normal
|
||||
; CHECK: catchpad within %cs2 [i32* %arg1]
|
||||
; CHECK-NEXT: br label %normal
|
||||
|
||||
catchswitch3:
|
||||
%cs3 = catchswitch within none [label %catchpad3] unwind label %cleanuppad1
|
||||
|
||||
catchpad3:
|
||||
catchpad [i32* %arg1, i32* %arg2] to label %normal unwind label %exn.3
|
||||
; CHECK: catchpad [i32* %arg1, i32* %arg2]
|
||||
; CHECK-NEXT: to label %normal unwind label %exn.3
|
||||
|
||||
exn.1:
|
||||
catchendpad unwind label %terminate.1
|
||||
; CHECK: catchendpad unwind label %terminate.1
|
||||
|
||||
exn.2:
|
||||
catchendpad unwind to caller
|
||||
; CHECK: catchendpad unwind to caller
|
||||
|
||||
exn.3:
|
||||
catchendpad unwind label %cleanuppad1
|
||||
; CHECK: catchendpad unwind label %cleanuppad1
|
||||
catchpad within %cs3 [i32* %arg1, i32* %arg2]
|
||||
br label %normal
|
||||
; CHECK: catchpad within %cs3 [i32* %arg1, i32* %arg2]
|
||||
; CHECK-NEXT: br label %normal
|
||||
|
||||
cleanuppad1:
|
||||
%clean.1 = cleanuppad []
|
||||
; CHECK: %clean.1 = cleanuppad []
|
||||
invoke void @f.ccc() to label %normal unwind label %cleanupendpad1
|
||||
|
||||
cleanupendpad1:
|
||||
cleanupendpad %clean.1 unwind label %terminate.2
|
||||
; CHECK: cleanupendpad %clean.1 unwind label %terminate.2
|
||||
%clean.1 = cleanuppad within none []
|
||||
; CHECK: %clean.1 = cleanuppad within none []
|
||||
invoke void @f.ccc() to label %normal unwind label %terminate.2
|
||||
|
||||
terminate.1:
|
||||
terminatepad [] unwind to caller
|
||||
; CHECK: terminatepad [] unwind to caller
|
||||
terminatepad within none [] unwind to caller
|
||||
; CHECK: terminatepad within none [] unwind to caller
|
||||
|
||||
terminate.2:
|
||||
terminatepad [i32* %arg1] unwind label %normal.pre
|
||||
; CHECK: terminatepad [i32* %arg1] unwind label %normal.pre
|
||||
terminatepad within %clean.1 [i32* %arg1] unwind label %normal.pre
|
||||
; CHECK: terminatepad within %clean.1 [i32* %arg1] unwind label %normal.pre
|
||||
|
||||
normal.pre:
|
||||
terminatepad [i32* %arg1, i32* %arg2] unwind to caller
|
||||
; CHECK: terminatepad [i32* %arg1, i32* %arg2] unwind to caller
|
||||
terminatepad within %clean.1 [i32* %arg1, i32* %arg2] unwind to caller
|
||||
; CHECK: terminatepad within %clean.1 [i32* %arg1, i32* %arg2] unwind to caller
|
||||
|
||||
normal:
|
||||
ret i32 0
|
||||
}
|
||||
|
||||
;
|
||||
define i32 @instructions.win_eh.2() personality i32 -4 {
|
||||
entry:
|
||||
invoke void @f.ccc() to label %invoke.cont unwind label %catchpad
|
||||
invoke void @f.ccc() to label %invoke.cont unwind label %catchswitch
|
||||
|
||||
invoke.cont:
|
||||
invoke void @f.ccc() to label %continue unwind label %cleanup
|
||||
|
||||
cleanup:
|
||||
%clean = cleanuppad []
|
||||
; CHECK: %clean = cleanuppad []
|
||||
cleanupret %clean unwind to caller
|
||||
; CHECK: cleanupret %clean unwind to caller
|
||||
%clean = cleanuppad within none []
|
||||
; CHECK: %clean = cleanuppad within none []
|
||||
cleanupret from %clean unwind to caller
|
||||
; CHECK: cleanupret from %clean unwind to caller
|
||||
|
||||
catchswitch:
|
||||
%cs = catchswitch within none [label %catchpad] unwind label %terminate
|
||||
|
||||
catchpad:
|
||||
%catch = catchpad [] to label %body unwind label %catchend
|
||||
; CHECK: %catch = catchpad []
|
||||
; CHECK-NEXT: to label %body unwind label %catchend
|
||||
%catch = catchpad within %cs []
|
||||
br label %body
|
||||
; CHECK: %catch = catchpad within %cs []
|
||||
; CHECK-NEXT: br label %body
|
||||
|
||||
body:
|
||||
invoke void @f.ccc() to label %continue unwind label %catchend
|
||||
catchret %catch to label %return
|
||||
; CHECK: catchret %catch to label %return
|
||||
invoke void @f.ccc() to label %continue unwind label %terminate
|
||||
catchret from %catch to label %return
|
||||
; CHECK: catchret from %catch to label %return
|
||||
|
||||
return:
|
||||
ret i32 0
|
||||
|
||||
catchend:
|
||||
catchendpad unwind label %terminate
|
||||
; CHECK: catchendpad unwind label %terminate
|
||||
|
||||
terminate:
|
||||
terminatepad [] unwind to caller
|
||||
; CHECK: terminatepad [] unwind to caller
|
||||
terminatepad within %cs [] unwind to caller
|
||||
; CHECK: terminatepad within %cs [] unwind to caller
|
||||
|
||||
continue:
|
||||
ret i32 0
|
||||
|
||||
Reference in New Issue
Block a user