From: Philip Reames Date: Fri, 24 Jul 2015 19:01:39 +0000 (+0000) Subject: [RewriteStatepointsForGC] Adjust naming scheme to be more stable X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fa2c630f798cd9df7b565f18cdf06821e294512e;p=platform%2Fupstream%2Fllvm.git [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. llvm-svn: 243140 --- diff --git a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp index 5a1fac0..aa30cfb 100644 --- a/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp +++ b/llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp @@ -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(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 diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll index 1ff1abed..8c360cd 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-1.ll @@ -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, ...) \ No newline at end of file +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll index f4292a9..61574e5 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-10.ll @@ -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, ...) \ No newline at end of file +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll index 90d91d2..9ffe086 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-4.ll @@ -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, ...) \ No newline at end of file +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...) diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll index 9b73377..a34e4cb 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-5.ll @@ -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) diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll index 0b785d7..ace2df2 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-6.ll @@ -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, ...) \ No newline at end of file +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidf(i64, i32, void ()*, i32, i32, ...) diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll index 467429b..c944f34 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers-7.ll @@ -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 ] diff --git a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll index 879f3f9..2b5b44a 100644 --- a/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll +++ b/llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll @@ -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, ...) \ No newline at end of file +declare i32 @llvm.experimental.gc.statepoint.p0f_isVoidp1i64f(i64, i32, void (i64 addrspace(1)*)*, i32, i32, ...)