mirror of
https://github.com/RPCSX/llvm.git
synced 2024-12-11 21:57:55 +00:00
[RewriteStatepointsForGC] Adjust naming scheme to be more stable
The names for instructions inserted were previous dependent on iteration order. By deriving the names from the original instructions, we can avoid instability in tests without resorting to ordered traversals. It also makes the IR mildly easier to read at large scale. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243140 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
e4a9f1b6e7
commit
ec2871f730
@ -858,13 +858,17 @@ static Value *findBasePointer(Value *I, DefiningValueMapTy &cache) {
|
||||
BasicBlock *BB = I->getParent();
|
||||
int NumPreds = std::distance(pred_begin(BB), pred_end(BB));
|
||||
assert(NumPreds > 0 && "how did we reach here");
|
||||
return PHINode::Create(I->getType(), NumPreds, "base_phi", I);
|
||||
std::string Name = I->hasName() ?
|
||||
(I->getName() + ".base").str() : "base_phi";
|
||||
return PHINode::Create(I->getType(), NumPreds, Name, I);
|
||||
}
|
||||
SelectInst *Sel = cast<SelectInst>(I);
|
||||
// The undef will be replaced later
|
||||
UndefValue *Undef = UndefValue::get(Sel->getType());
|
||||
std::string Name = I->hasName() ?
|
||||
(I->getName() + ".base").str() : "base_select";
|
||||
return SelectInst::Create(Sel->getCondition(), Undef,
|
||||
Undef, "base_select", Sel);
|
||||
Undef, Name, Sel);
|
||||
};
|
||||
Instruction *BaseInst = MakeBaseInstPlaceholder(I);
|
||||
// Add metadata marking this as a base value
|
||||
@ -1283,7 +1287,7 @@ makeStatepointExplicitImpl(const CallSite &CS, /* to replace */
|
||||
// original block.
|
||||
InvokeInst *invoke = InvokeInst::Create(
|
||||
gc_statepoint_decl, toReplace->getNormalDest(),
|
||||
toReplace->getUnwindDest(), args, "", toReplace->getParent());
|
||||
toReplace->getUnwindDest(), args, "statepoint_token", toReplace->getParent());
|
||||
invoke->setCallingConv(toReplace->getCallingConv());
|
||||
|
||||
// Currently we will fail on parameter attributes and on certain
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %base_phi
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
@ -18,11 +18,11 @@ there:
|
||||
|
||||
merge:
|
||||
; CHECK-LABEL: merge:
|
||||
; CHECK: %base_phi = phi i64 addrspace(1)* [ %base_obj_x, %here ], [ %base_obj_y, %there ]
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %here ], [ %base_obj_y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %x, %here ], [ %y, %there ]
|
||||
%safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
|
||||
ret i64 addrspace(1)* %merged_value
|
||||
}
|
||||
|
||||
declare void @foo()
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
|
@ -1,8 +1,9 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %next_x base %base_obj_x
|
||||
; CHECK: derived %next_y base %base_obj_y
|
||||
; CHECK: derived %next base %base_phi
|
||||
; CHECK: Base Pairs (w/o Relocation):
|
||||
; CHECK-DAG: derived %next base %next.base
|
||||
; CHECK-DAG: derived %next_x base %base_obj_x
|
||||
; CHECK-DAG: derived %next_y base %base_obj_y
|
||||
|
||||
declare i1 @runtime_value()
|
||||
declare void @do_safepoint()
|
||||
@ -34,4 +35,4 @@ merge:
|
||||
br label %loop
|
||||
}
|
||||
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
|
@ -1,7 +1,7 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
|
||||
; CHECK: derived %obj_to_consume base %base_phi
|
||||
; CHECK: derived %obj_to_consume base %obj_to_consume.base
|
||||
|
||||
declare void @foo()
|
||||
declare i64 addrspace(1)* @generate_obj()
|
||||
@ -33,7 +33,7 @@ dest_c:
|
||||
|
||||
merge:
|
||||
; CHECK: merge:
|
||||
; CHECK: %base_phi = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
; CHECK: %obj_to_consume.base = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
; CHECK: %obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
|
||||
%obj_to_consume = phi i64 addrspace(1)* [ %obj2, %dest_a ], [ null, %dest_b ], [ null, %dest_c ]
|
||||
@ -50,4 +50,4 @@ merge.split: ; preds = %merge
|
||||
declare i64 addrspace(1)* @llvm.experimental.gc.result.p1i64(i32) #0
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_p1i64f(i64, i32, i64 addrspace(1)* ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %base_phi
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @foo()
|
||||
|
||||
@ -20,7 +20,7 @@ there:
|
||||
|
||||
merge:
|
||||
; CHECK: merge:
|
||||
; CHECK: %base_phi = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %base_obj_y, %there ]
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %base_obj_y, %there ]
|
||||
; CHECK-NEXT: %merged_value = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %base_obj_x, %bump ], [ %y, %there ]
|
||||
%safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @foo, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %base_phi
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
@ -30,7 +30,7 @@ there:
|
||||
|
||||
merge:
|
||||
; CHECK: merge:
|
||||
; CHECK: %base_phi = phi i64 addrspace(1)* [ %base_obj_x, %merge_here ], [ %base_obj_y, %there ]
|
||||
; CHECK: %merged_value.base = phi i64 addrspace(1)* [ %base_obj_x, %merge_here ], [ %base_obj_y, %there ]
|
||||
; CHECK-NEXT: %merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
%merged_value = phi i64 addrspace(1)* [ %x, %merge_here ], [ %y, %there ]
|
||||
%safepoint_token = call i32 (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 0, i32 0, void ()* @site_for_call_safpeoint, i32 0, i32 0, i32 0, i32 5, i32 0, i32 -1, i32 0, i32 0, i32 0)
|
||||
@ -38,4 +38,4 @@ merge:
|
||||
}
|
||||
|
||||
declare void @do_safepoint()
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
|
@ -1,6 +1,6 @@
|
||||
; RUN: opt %s -rewrite-statepoints-for-gc -spp-print-base-pointers -S 2>&1 | FileCheck %s
|
||||
|
||||
; CHECK: derived %merged_value base %base_phi
|
||||
; CHECK: derived %merged_value base %merged_value.base
|
||||
|
||||
declare void @site_for_call_safpeoint()
|
||||
|
||||
@ -24,7 +24,7 @@ bump_here_b:
|
||||
|
||||
merge_here:
|
||||
; CHECK: merge_here:
|
||||
; CHECK-DAG: %base_phi
|
||||
; CHECK-DAG: %x.base
|
||||
; CHECK-DAG: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %base_obj_x, %bump_here_a ]
|
||||
; CHECK-DAG: [ %base_obj_y, %bump_here_b ]
|
||||
@ -37,7 +37,7 @@ there:
|
||||
|
||||
merge:
|
||||
; CHECK: merge:
|
||||
; CHECK-DAG: %base_phi1
|
||||
; CHECK-DAG: %merged_value.base
|
||||
; CHECK-DAG: phi i64 addrspace(1)*
|
||||
; CHECK-DAG: %merge_here
|
||||
; CHECK-DAG: [ %base_obj_y, %there ]
|
||||
|
@ -55,7 +55,7 @@ define i64 addrspace(1)* @test1(i32 %caller, i8 addrspace(1)* %a, i8 addrspace(1
|
||||
|
||||
merge:
|
||||
; CHECK: merge:
|
||||
; CHECK-NEXT: %base_phi = phi i64 addrspace(1)* [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_R]], %right ], !is_base_value !0
|
||||
; CHECK-NEXT: %value.base = phi i64 addrspace(1)* [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_L]], %left ], [ [[CAST_R]], %right ], !is_base_value !0
|
||||
%value = phi i64 addrspace(1)* [ %a.cast, %left], [ %a.cast, %left], [ %a.cast, %left], [ %b.cast, %right]
|
||||
%safepoint_token = call i32 (i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64 0, i32 0, void (i64 addrspace(1)*)* @parse_point, i32 1, i32 0, i64 addrspace(1)* %value, i32 0, i32 5, i32 0, i32 0, i32 0, i32 0, i32 0)
|
||||
|
||||
@ -74,16 +74,16 @@ entry:
|
||||
|
||||
loop: ; preds = %loop, %entry
|
||||
; CHECK-LABEL: loop
|
||||
; CHECK: %base_phi = phi i64 addrspace(1)*
|
||||
; CHECK: %current.base = phi i64 addrspace(1)*
|
||||
; CHECK-DAG: [ %base_obj, %entry ]
|
||||
; Given the two selects are equivelent, so are their base phis - ideally,
|
||||
; we'd have commoned these, but that's a missed optimization, not correctness.
|
||||
; CHECK-DAG: [ [[DISCARD:%base_select.*.relocated.casted]], %loop ]
|
||||
; CHECK-NOT: base_phi2
|
||||
; CHECK-DAG: [ [[DISCARD:%.*.base.relocated.casted]], %loop ]
|
||||
; CHECK-NOT: extra.base
|
||||
; CHECK: next.base = select
|
||||
; CHECK: next = select
|
||||
; CHECK: base_select
|
||||
; CHECK: extra2.base = select
|
||||
; CHECK: extra2 = select
|
||||
; CHECK: base_select
|
||||
; CHECK: statepoint
|
||||
;; Both 'next' and 'extra2' are live across the backedge safepoint...
|
||||
%current = phi i64 addrspace(1)* [ %obj, %entry ], [ %next, %loop ]
|
||||
@ -97,4 +97,4 @@ loop: ; preds = %loop, %entry
|
||||
|
||||
declare void @foo()
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)
|
||||
declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)
|
||||
|
Loading…
Reference in New Issue
Block a user