[PATCH] D97885: [rs4gc] avoid insert base computation instructions for deopt uses
Philip Reames via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 5 09:58:42 PST 2021
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG99f93dd3a502: [rs4gc] avoid insert base computation instructions for deopt uses (authored by reames).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97885/new/
https://reviews.llvm.org/D97885
Files:
llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll
Index: llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll
===================================================================
--- llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll
+++ llvm/test/Transforms/RewriteStatepointsForGC/scalar-base-vector.ll
@@ -147,24 +147,20 @@
; CHECK-NEXT: bb:
; CHECK-NEXT: br label [[HEADER:%.*]]
; CHECK: header:
-; CHECK-NEXT: [[TMP_BASE:%.*]] = phi i8 addrspace(1)* [ [[TMP6_BASE:%.*]], [[LATCH:%.*]] ], [ null, [[BB:%.*]] ], !is_base_value !0
-; CHECK-NEXT: [[TMP:%.*]] = phi i8 addrspace(1)* [ [[TMP6:%.*]], [[LATCH]] ], [ undef, [[BB]] ]
+; CHECK-NEXT: [[TMP:%.*]] = phi i8 addrspace(1)* [ [[TMP6:%.*]], [[LATCH:%.*]] ], [ undef, [[BB:%.*]] ]
; CHECK-NEXT: br label [[BB10:%.*]]
; CHECK: bb10:
-; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @spam, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i8 addrspace(1)* [[TMP]]), "gc-live"(i8 addrspace(1)* [[TMP]], i8 addrspace(1)* [[TMP_BASE]]) ]
-; CHECK-NEXT: [[TMP_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 0)
-; CHECK-NEXT: [[TMP_BASE_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 1, i32 1)
+; CHECK-NEXT: [[STATEPOINT_TOKEN:%.*]] = call token (i64, i32, void ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_isVoidf(i64 2882400000, i32 0, void ()* @spam, i32 0, i32 0, i32 0, i32 0) [ "deopt"(i8 addrspace(1)* [[TMP]]), "gc-live"(i8 addrspace(1)* [[TMP]]) ]
+; CHECK-NEXT: [[TMP_RELOCATED:%.*]] = call coldcc i8 addrspace(1)* @llvm.experimental.gc.relocate.p1i8(token [[STATEPOINT_TOKEN]], i32 0, i32 0)
; CHECK-NEXT: br label [[BB25:%.*]]
; CHECK: bb25:
; CHECK-NEXT: [[STATEPOINT_TOKEN1:%.*]] = call token (i64, i32, <2 x i8 addrspace(1)*> ()*, i32, i32, ...) @llvm.experimental.gc.statepoint.p0f_v2p1i8f(i64 2882400000, i32 0, <2 x i8 addrspace(1)*> ()* @baz, i32 0, i32 0, i32 0, i32 0)
; CHECK-NEXT: [[TMP262:%.*]] = call <2 x i8 addrspace(1)*> @llvm.experimental.gc.result.v2p1i8(token [[STATEPOINT_TOKEN1]])
-; CHECK-NEXT: [[BASE_EE:%.*]] = extractelement <2 x i8 addrspace(1)*> [[TMP262]], i32 0, !is_base_value !0
; CHECK-NEXT: [[TMP27:%.*]] = extractelement <2 x i8 addrspace(1)*> [[TMP262]], i32 0
; CHECK-NEXT: br i1 undef, label [[BB7:%.*]], label [[LATCH]]
; CHECK: bb7:
; CHECK-NEXT: br label [[LATCH]]
; CHECK: latch:
-; CHECK-NEXT: [[TMP6_BASE]] = phi i8 addrspace(1)* [ [[BASE_EE]], [[BB25]] ], [ [[BASE_EE]], [[BB7]] ], !is_base_value !0
; CHECK-NEXT: [[TMP6]] = phi i8 addrspace(1)* [ [[TMP27]], [[BB25]] ], [ [[TMP27]], [[BB7]] ]
; CHECK-NEXT: br label [[HEADER]]
;
Index: llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
===================================================================
--- llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
+++ llvm/test/Transforms/RewriteStatepointsForGC/base-pointers.ll
@@ -152,4 +152,24 @@
ret i64 addrspace(1)* %bdv
}
+; We know from the deopt use that %bdv must be a base value, and as
+; result can avoid materializing the extra copy of the BDV phi node.
+; (Even without a general forward analysis)
+define i64 addrspace(1)* @test6(i1 %cnd, i64 addrspace(1)* %obj, i64 addrspace(1)* %obj2) gc "statepoint-example" {
+; CHECK-LABEL: @test6
+entry:
+ br label %merge
+
+merge: ; preds = %merge, %entry
+; CHECK-LABEL: merge:
+; CHECK-NEXT: phi
+; CHECK-NEXT: br i1
+ %bdv = phi i64 addrspace(1)* [ %obj, %entry ], [ %obj2, %merge ]
+ br i1 %cnd, label %merge, label %next
+
+next: ; preds = %merge
+ call void @foo() [ "deopt"(i64 addrspace(1)* %bdv) ]
+ ret i64 addrspace(1)* %bdv
+}
+
declare void @foo()
Index: llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
+++ llvm/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
@@ -1236,7 +1236,20 @@
CallBase *Call,
PartiallyConstructedSafepointRecord &result) {
MapVector<Value *, Value *> PointerToBase;
- findBasePointers(result.LiveSet, PointerToBase, &DT, DVCache);
+ StatepointLiveSetTy PotentiallyDerivedPointers = result.LiveSet;
+ // We assume that all pointers passed to deopt are base pointers; as an
+ // optimization, we can use this to avoid seperately materializing the base
+ // pointer graph. This is only relevant since we're very conservative about
+ // generating new conflict nodes during base pointer insertion. If we were
+ // smarter there, this would be irrelevant.
+ if (auto Opt = Call->getOperandBundle(LLVMContext::OB_deopt))
+ for (Value *V : Opt->Inputs) {
+ if (!PotentiallyDerivedPointers.count(V))
+ continue;
+ PotentiallyDerivedPointers.remove(V);
+ PointerToBase[V] = V;
+ }
+ findBasePointers(PotentiallyDerivedPointers, PointerToBase, &DT, DVCache);
if (PrintBasePointers) {
errs() << "Base Pairs (w/o Relocation):\n";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97885.328568.patch
Type: text/x-patch
Size: 5331 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210305/2e3e7819/attachment.bin>
More information about the llvm-commits
mailing list