[PATCH] D123530: Optimize cross block gc.relocate lowering. NFC.
Denis Antrushin via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 22 10:38:36 PDT 2022
dantrushin updated this revision to Diff 424530.
dantrushin added a comment.
Update test comment lost during merge
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D123530/new/
https://reviews.llvm.org/D123530
Files:
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
llvm/test/CodeGen/X86/statepoint-vreg-details.ll
Index: llvm/test/CodeGen/X86/statepoint-vreg-details.ll
===================================================================
--- llvm/test/CodeGen/X86/statepoint-vreg-details.ll
+++ llvm/test/CodeGen/X86/statepoint-vreg-details.ll
@@ -342,14 +342,14 @@
ret i8 addrspace(1)* %res
}
-; Show that ISEL of gc.relocate used in other BB does generate extra COPY instruction.
+; Check that ISEL of gc.relocate used in other BB does not generate extra COPY instruction.
define i1 @test_cross_bb_reloc(i32 addrspace(1)* %a, i1 %external_cond) gc "statepoint-example" {
; CHECK-VREG_LABEL: test_cross_bb_reloc:
; CHECK-VREG: bb.0.entry:
; CHECK-VREG: [[VREG:%[^ ]+]]:gr64 = STATEPOINT 0, 0, 0, @return_i1, 2, 0, 2, 0, 2, 0, 2, 1, %2(tied-def 0), 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp, implicit-def $al
-; CHECK-VREG: [[EXTRA:%[^ ]+]]:gr64 = COPY [[VREG]]
+; CHECK-VREG-NOT: COPY [[VREG]]
; CHECK-VREG: bb.1.left:
-; CHECK-VREG: $rdi = COPY [[EXTRA]]
+; CHECK-VREG: $rdi = COPY [[VREG]]
; CHECK-VREG: CALL64pcrel32 @consume, csr_64, implicit $rsp, implicit $ssp, implicit $rdi, implicit-def $rsp, implicit-def $ssp
; CHECK-VREG: $al = COPY %1
; CHECK-VREG: RET 0, $al
Index: llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
+++ llvm/lib/CodeGen/SelectionDAG/StatepointLowering.cpp
@@ -1231,6 +1231,8 @@
SDValue Relocation = RFV.getCopyFromRegs(DAG, FuncInfo, getCurSDLoc(),
Chain, nullptr, nullptr);
setValue(&Relocate, Relocation);
+ // Reuse corresponding statepoint register.
+ FuncInfo.ValueMap[&Relocate] = InReg;
return;
}
@@ -1263,22 +1265,22 @@
assert(SpillLoad.getNode());
setValue(&Relocate, SpillLoad);
- return;
- }
+ } else {
- assert(Record.type == RecordType::NoRelocate);
- SDValue SD = getValue(DerivedPtr);
+ assert(Record.type == RecordType::NoRelocate);
+ SDValue SD = getValue(DerivedPtr);
- if (SD.isUndef() && SD.getValueType().getSizeInBits() <= 64) {
- // Lowering relocate(undef) as arbitrary constant. Current constant value
- // is chosen such that it's unlikely to be a valid pointer.
- setValue(&Relocate, DAG.getTargetConstant(0xFEFEFEFE, SDLoc(SD), MVT::i64));
- return;
- }
+ if (SD.isUndef() && SD.getValueType().getSizeInBits() <= 64) {
+ // Lowering relocate(undef) as arbitrary constant. Current constant value
+ // is chosen such that it's unlikely to be a valid pointer.
+ SD = DAG.getTargetConstant(0xFEFEFEFE, SDLoc(SD), MVT::i64);
+ }
- // We didn't need to spill these special cases (constants and allocas).
- // See the handling in spillIncomingValueForStatepoint for detail.
- setValue(&Relocate, SD);
+ // We didn't need to spill these special cases (constants and allocas).
+ // See the handling in spillIncomingValueForStatepoint for detail.
+ setValue(&Relocate, SD);
+ }
+ CopyToExportRegsIfNeeded(&Relocate);
}
void SelectionDAGBuilder::LowerDeoptimizeCall(const CallInst *CI) {
Index: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
===================================================================
--- llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1124,8 +1124,9 @@
visit(I.getOpcode(), I);
- if (!I.isTerminator() && !HasTailCall &&
- !isa<GCStatepointInst>(I)) // statepoints handle their exports internally
+ // statepoints and relocates handle their exports internally
+ if (!I.isTerminator() && !HasTailCall && !isa<GCStatepointInst>(I) &&
+ !isa<GCRelocateInst>(I))
CopyToExportRegsIfNeeded(&I);
CurInst = nullptr;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D123530.424530.patch
Type: text/x-patch
Size: 3836 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220422/afe8a2e5/attachment.bin>
More information about the llvm-commits
mailing list