llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-backend-amdgpu Author: Piyou Chen (BeMg) <details> <summary>Changes</summary> This is patch 2 of 4. Together, they adjust `tryAssignCSRFirstTime` and the `getCSRCost` value to improve prologue/epilogue codegen in benchmarks. - https://github.com/llvm/llvm-project/pull/239526 - https://github.com/llvm/llvm-project/pull/239530 - https://github.com/llvm/llvm-project/pull/239532 - https://github.com/llvm/llvm-project/pull/239534 ----- This patch add the `tryAssignCSRFirstTimeMinCost` to provide more choices than `tryAssignCSRFirstTime` when Greedy RegAlloc try to assigned the unused CSR to VirtReg. This feature control by `enableCSRFirstTimeMinCost` target hook. --- Patch is 312.92 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/239530.diff 35 Files Affected: - (modified) llvm/include/llvm/CodeGen/TargetRegisterInfo.h (+10) - (modified) llvm/lib/CodeGen/RegAllocGreedy.cpp (+133-12) - (modified) llvm/lib/CodeGen/RegAllocGreedy.h (+6) - (modified) llvm/lib/Target/AMDGPU/SIRegisterInfo.h (+9) - (modified) llvm/test/CodeGen/AArch64/call-rv-marker.ll (+27-24) - (modified) llvm/test/CodeGen/AArch64/sme-za-exceptions.ll (+21-26) - (modified) llvm/test/CodeGen/AMDGPU/bf16.ll (+148-158) - (modified) llvm/test/CodeGen/AMDGPU/fcopysign.bf16.ll (+181-215) - (modified) llvm/test/CodeGen/AMDGPU/fcopysign.f16.ll (+91-108) - (modified) llvm/test/CodeGen/AMDGPU/infloop-subrange-spill-inspect-subrange.mir (+18-22) - (modified) llvm/test/CodeGen/AMDGPU/infloop-subrange-spill.mir (+17-20) - (modified) llvm/test/CodeGen/AMDGPU/issue48473.mir (+1-1) - (modified) llvm/test/CodeGen/AMDGPU/large-avgpr-assign-last.mir (+5-5) - (modified) llvm/test/CodeGen/AMDGPU/maximumnum.bf16.ll (+202-202) - (modified) llvm/test/CodeGen/AMDGPU/maximumnum.ll (+217-230) - (modified) llvm/test/CodeGen/AMDGPU/minimumnum.bf16.ll (+202-202) - (modified) llvm/test/CodeGen/AMDGPU/minimumnum.ll (+217-230) - (modified) llvm/test/CodeGen/AMDGPU/select.f16.ll (+84-84) - (modified) llvm/test/CodeGen/RISCV/csr-first-use-cost.ll (+9-9) - (modified) llvm/test/CodeGen/RISCV/exception-pointer-register.ll (+14-22) - (modified) llvm/test/CodeGen/X86/2007-08-09-IllegalX86-64Asm.ll (+11-13) - (modified) llvm/test/CodeGen/X86/2007-11-30-LoadFolding-Bug.ll (+36-37) - (modified) llvm/test/CodeGen/X86/2008-04-16-ReMatBug.ll (+18-17) - (modified) llvm/test/CodeGen/X86/2008-04-17-CoalescerBug.ll (+11-19) - (modified) llvm/test/CodeGen/X86/apx/memfold-origVNI-crash.ll (+43-47) - (modified) llvm/test/CodeGen/X86/atom-fixup-lea2.ll (+2-2) - (modified) llvm/test/CodeGen/X86/call-rv-marker.ll (+3-6) - (modified) llvm/test/CodeGen/X86/csr-split.ll (+4-5) - (modified) llvm/test/CodeGen/X86/expand-large-fp-optnone.ll (+48-62) - (modified) llvm/test/CodeGen/X86/i386-shrink-wrapping.ll (+2-2) - (modified) llvm/test/CodeGen/X86/lrshrink-ehpad-phis.ll (+14-14) - (modified) llvm/test/CodeGen/X86/ragreedy-hoist-spill.ll (+20-20) - (modified) llvm/test/CodeGen/X86/speculative-load-hardening.ll (+15-21) - (modified) llvm/test/CodeGen/X86/throws-cfi-fp.ll (+2-5) - (modified) llvm/test/CodeGen/X86/throws-cfi-no-fp.ll (+1-1) ``````````diff diff --git a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h index fc3b4d6dda844..880a48df56466 100644 --- a/llvm/include/llvm/CodeGen/TargetRegisterInfo.h +++ b/llvm/include/llvm/CodeGen/TargetRegisterInfo.h @@ -899,6 +899,16 @@ class LLVM_ABI TargetRegisterInfo : public MCRegisterInfo { return 30; } + /// Return true if the RegAlloc can spill instead of using an unused CSR, + /// when the spill costs less than the CSR cost. Return false if a spill + /// on this target is not comparable with the CSR cost, for example when + /// a spill does not go to the stack. + virtual bool + shouldSpillInsteadOfFirstCSRUse(const MachineFunction &MF, + const LiveInterval &VirtReg) const { + return true; + } + /// Returns true if the target requires (and can make use of) the register /// scavenger. virtual bool requiresRegisterScavenging(const MachineFunction &MF) const { diff --git a/llvm/lib/CodeGen/RegAllocGreedy.cpp b/llvm/lib/CodeGen/RegAllocGreedy.cpp index f7655e97b9942..55c11987c0898 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.cpp +++ b/llvm/lib/CodeGen/RegAllocGreedy.cpp @@ -2471,6 +2471,50 @@ BlockFrequency RAGreedy::calcRematCost(const LiveInterval &VirtReg, return HasUse ? RematCost : BlockFrequency::max(); } +/// Return true if the spiller can rematerialize each use of LI. +/// And it can rematerialize for only one def, which does not load. +static bool isRematerializableFromOriginal(const LiveInterval &LI, + const LiveIntervals &LIS, + const VirtRegMap &VRM, + const MachineRegisterInfo &MRI, + const TargetInstrInfo &TII) { + const LiveInterval &OrigLI = LIS.getInterval(VRM.getOriginal(LI.reg())); + const MachineInstr *Def = nullptr; + for (const VNInfo *VNI : OrigLI.valnos) { + if (VNI->isUnused()) + continue; + // The original live range must have only one def. + if (VNI->isPHIDef() || Def) + return false; + Def = LIS.getInstructionFromIndex(VNI->def); + if (!Def || !TII.isReMaterializable(*Def) || Def->mayLoad()) + return false; + } + if (!Def) + return false; + for (const MachineInstr &MI : MRI.use_nodbg_instructions(LI.reg())) + if (!canGuaranteeAssignmentAfterRemat(LI.reg(), MI) || + !VirtRegAuxInfo::allUsesAvailableAt(Def, LIS.getInstructionIndex(MI), + LIS, MRI, TII)) + return false; + return true; +} + +/// The cost of rematerializing \p LI before each of its uses. +static BlockFrequency calcRematCostAtUses(const LiveInterval &LI, + const MachineRegisterInfo &MRI, + const SpillPlacement &SpillPlacer) { + uint64_t RematCost = 0; + SmallPtrSet<const MachineInstr *, 8> Seen; + for (const MachineInstr &MI : MRI.use_nodbg_instructions(LI.reg())) { + if (MI.isMetaInstruction() || !Seen.insert(&MI).second) + continue; + RematCost += SpillPlacer.getBlockFrequency(MI.getParent()->getNumber()) + .getFrequency(); + } + return BlockFrequency(RematCost); +} + /// Using a CSR for the first time has a cost because it causes push|pop /// to be added to prologue|epilogue. Splitting a cold section of the live /// range can have lower cost than using the CSR for the first time; @@ -2482,6 +2526,10 @@ MCRegister RAGreedy::tryAssignCSRFirstTime( uint8_t &CostPerUseLimit, SmallVectorImpl<Register> &NewVRegs) { LiveRangeStage Stage = ExtraInfo->getStage(VirtReg); + // For RS_Done, just use the CSR. + if (Stage > RS_Spill) + return PhysReg; + if (Stage == RS_Spill && VirtReg.isSpillable()) { // We choose spill or rematerialize over using the CSR for the first time if // the spill cost is lower than CSRCost. @@ -2496,34 +2544,107 @@ MCRegister RAGreedy::tryAssignCSRFirstTime( CostPerUseLimit = 1; return MCRegister(); } + + // The lowest cost of rematerializing or spilling VirtReg. + BlockFrequency SpillCost = BlockFrequency::max(); + if (VirtReg.isSpillable()) { + if (isRematerializableFromOriginal(VirtReg, *LIS, *VRM, *MRI, *TII)) + SpillCost = calcRematCostAtUses(VirtReg, *MRI, *SpillPlacer); + if (TRI->shouldSpillInsteadOfFirstCSRUse(*MF, VirtReg)) + SpillCost = std::min(SpillCost, calcSpillCost(VirtReg)); + } + if (Stage < RS_Split) { // We choose pre-splitting over using the CSR for the first time if - // the cost of splitting is lower than CSRCost. + // the cost of splitting is lower than CSRCost and the remat/spill cost. SA->analyze(&VirtReg); unsigned NumCands = 0; BlockFrequency BestCost = CSRCost; // Don't modify CSRCost. unsigned BestCand = calculateRegionSplitCost(VirtReg, Order, BestCost, NumCands, true /*IgnoreCSR*/); - if (BestCand == NoCand) { - if (calcRematCost(VirtReg, Order) < CSRCost) { - CostPerUseLimit = 1; - return MCRegister(); - } - // Use the CSR if we can't find a region split below CSRCost. - return PhysReg; + if (BestCand != NoCand && BestCost <= SpillCost) { + // Perform the actual pre-splitting. + doRegionSplit(VirtReg, BestCand, false /*HasCompact*/, NewVRegs); + return MCRegister(); } - - // Perform the actual pre-splitting. - doRegionSplit(VirtReg, BestCand, false/*HasCompact*/, NewVRegs); - return MCRegister(); } if (calcRematCost(VirtReg, Order) < CSRCost) { CostPerUseLimit = 1; return MCRegister(); } + // Evict rematerializable live ranges from a register that is not an unused + // CSR, if that costs less than CSRCost and the spill cost. + if (MCRegister Reg = tryEvictRematForCSR(VirtReg, Order, NewVRegs, + std::min(CSRCost, SpillCost))) + return Reg; + // We choose spilling or rematerialization over using the CSR for the first + // time if it costs less than CSRCost. + if (SpillCost < CSRCost) { + // Set CostPerUseLimit to 1 to make sure that we will not use a + // callee-saved register in tryEvict. + ExtraInfo->setStage(VirtReg, RS_Spill); + CostPerUseLimit = 1; + return MCRegister(); + } + // Use the CSR if no other choice costs less than CSRCost. return PhysReg; } +/// Return the cost of evicting and rematerializing all the live ranges that +/// interfere with VirtReg in PhysReg. +/// Return BlockFrequency::max() when one of these live ranges +/// 1. has a Cascade that is not lower than Cascade, +/// 2. can't be spilled, or +/// 3. can't be rematerialized. +BlockFrequency RAGreedy::calcEvictRematCost(const LiveInterval &VirtReg, + MCRegister PhysReg, + unsigned Cascade) const { + BlockFrequency Cost(0); + SmallPtrSet<const LiveInterval *, 4> Seen; + for (MCRegUnit Unit : TRI->regunits(PhysReg)) { + for (const LiveInterval *Intf : + Matrix->query(VirtReg, Unit).interferingVRegs()) { + if (!Seen.insert(Intf).second) + continue; + if (ExtraInfo->getCascade(Intf->reg()) >= Cascade || + !Intf->isSpillable() || + !isRematerializableFromOriginal(*Intf, *LIS, *VRM, *MRI, *TII)) + return BlockFrequency::max(); + Cost += calcRematCostAtUses(*Intf, *MRI, *SpillPlacer); + } + } + return Cost; +} + +/// Before VirtReg uses a CSR for the first time, look for a register that +/// is not an unused CSR and that only rematerializable live ranges occupy. +/// If rematerializing them costs less than MaxCost, evict them and +/// return the register. +MCRegister RAGreedy::tryEvictRematForCSR(const LiveInterval &VirtReg, + AllocationOrder &Order, + SmallVectorImpl<Register> &NewVRegs, + BlockFrequency MaxCost) { + unsigned Cascade = ExtraInfo->getCascadeOrCurrentNext(VirtReg.reg()); + MCRegister BestReg; + BlockFrequency BestCost = MaxCost; + for (MCRegister PhysReg : Order.getOrder()) { + if (EvictAdvisor->getUnusedCalleeSavedReg(VirtReg, PhysReg) || + Matrix->checkInterference(VirtReg, PhysReg) != + LiveRegMatrix::IK_VirtReg) + continue; + BlockFrequency Cost = calcEvictRematCost(VirtReg, PhysReg, Cascade); + if (Cost < BestCost) { + BestCost = Cost; + BestReg = PhysReg; + } + } + if (!BestReg) + return MCRegister(); + + evictInterference(VirtReg, BestReg, NewVRegs); + return BestReg; +} + void RAGreedy::aboutToRemoveInterval(const LiveInterval &LI) { // Do not keep invalid information around. SetOfBrokenHints.remove(&LI); diff --git a/llvm/lib/CodeGen/RegAllocGreedy.h b/llvm/lib/CodeGen/RegAllocGreedy.h index 138da362a1e76..16273854eaaf6 100644 --- a/llvm/lib/CodeGen/RegAllocGreedy.h +++ b/llvm/lib/CodeGen/RegAllocGreedy.h @@ -365,6 +365,12 @@ class LLVM_LIBRARY_VISIBILITY RAGreedy : public RegAllocBase, /// rematerialization is not possible. BlockFrequency calcRematCost(const LiveInterval &VirtReg, AllocationOrder &Order) const; + BlockFrequency calcEvictRematCost(const LiveInterval &VirtReg, + MCRegister PhysReg, unsigned Cascade) const; + MCRegister tryEvictRematForCSR(const LiveInterval &VirtReg, + AllocationOrder &Order, + SmallVectorImpl<Register> &NewVRegs, + BlockFrequency MaxCost); BlockFrequency calcSpillCost(const LiveInterval &LI); void initializeCSRCost(); MCRegister tryBlockSplit(const LiveInterval &, AllocationOrder &, diff --git a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h index 4cacba0ed2592..a1362f34848e2 100644 --- a/llvm/lib/Target/AMDGPU/SIRegisterInfo.h +++ b/llvm/lib/Target/AMDGPU/SIRegisterInfo.h @@ -128,6 +128,15 @@ class SIRegisterInfo final : public AMDGPUGenRegisterInfo { return 27; } + bool + shouldSpillInsteadOfFirstCSRUse(const MachineFunction &MF, + const LiveInterval &VirtReg) const override { + // An SGPR spill goes to a VGPR lane, like a CSR SGPR save, but at each use, + // and it needs one more WWM VGPR. getCSRFirstUseCost also models occupancy, + // so it is not comparable with the spill cost. + return false; + } + bool shouldCompactSlotIndexes(const MachineFunction &MF) const override { return true; } diff --git a/llvm/test/CodeGen/AArch64/call-rv-marker.ll b/llvm/test/CodeGen/AArch64/call-rv-marker.ll index a2a9138f57f9a..682f0435ab0dd 100644 --- a/llvm/test/CodeGen/AArch64/call-rv-marker.ll +++ b/llvm/test/CodeGen/AArch64/call-rv-marker.ll @@ -89,9 +89,10 @@ define dso_local void @rv_marker_3() personality ptr @__gxx_personality_v0 { ; CHECK-SD-NEXT: .cfi_personality 155, ___gxx_personality_v0 ; CHECK-SD-NEXT: .cfi_lsda 16, Lexception0 ; CHECK-SD-NEXT: ; %bb.0: ; %entry -; CHECK-SD-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill -; CHECK-SD-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill -; CHECK-SD-NEXT: .cfi_def_cfa_offset 32 +; CHECK-SD-NEXT: sub sp, sp, #48 +; CHECK-SD-NEXT: stp x20, x19, [sp, #16] ; 16-byte Folded Spill +; CHECK-SD-NEXT: stp x29, x30, [sp, #32] ; 16-byte Folded Spill +; CHECK-SD-NEXT: .cfi_def_cfa_offset 48 ; CHECK-SD-NEXT: .cfi_offset w30, -8 ; CHECK-SD-NEXT: .cfi_offset w29, -16 ; CHECK-SD-NEXT: .cfi_offset w19, -24 @@ -104,16 +105,17 @@ define dso_local void @rv_marker_3() personality ptr @__gxx_personality_v0 { ; CHECK-SD-NEXT: bl _objc_object ; CHECK-SD-NEXT: Ltmp1: ; EH_LABEL ; CHECK-SD-NEXT: ; %bb.1: ; %invoke.cont -; CHECK-SD-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload ; CHECK-SD-NEXT: mov x0, x19 -; CHECK-SD-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload +; CHECK-SD-NEXT: ldp x29, x30, [sp, #32] ; 16-byte Folded Reload +; CHECK-SD-NEXT: ldp x20, x19, [sp, #16] ; 16-byte Folded Reload +; CHECK-SD-NEXT: add sp, sp, #48 ; CHECK-SD-NEXT: b _objc_release ; CHECK-SD-NEXT: LBB3_2: ; %lpad ; CHECK-SD-NEXT: Ltmp2: ; EH_LABEL -; CHECK-SD-NEXT: mov x20, x0 +; CHECK-SD-NEXT: str x0, [sp, #8] ; 8-byte Spill ; CHECK-SD-NEXT: mov x0, x19 ; CHECK-SD-NEXT: bl _objc_release -; CHECK-SD-NEXT: mov x0, x20 +; CHECK-SD-NEXT: ldr x0, [sp, #8] ; 8-byte Reload ; CHECK-SD-NEXT: bl __Unwind_Resume ; CHECK-SD-NEXT: Lfunc_end0: ; CHECK-SD-NEXT: .cfi_endproc @@ -147,9 +149,10 @@ define dso_local void @rv_marker_3() personality ptr @__gxx_personality_v0 { ; CHECK-GI-NEXT: .cfi_personality 155, ___gxx_personality_v0 ; CHECK-GI-NEXT: .cfi_lsda 16, Lexception0 ; CHECK-GI-NEXT: ; %bb.0: ; %entry -; CHECK-GI-NEXT: stp x20, x19, [sp, #-32]! ; 16-byte Folded Spill -; CHECK-GI-NEXT: stp x29, x30, [sp, #16] ; 16-byte Folded Spill -; CHECK-GI-NEXT: .cfi_def_cfa_offset 32 +; CHECK-GI-NEXT: sub sp, sp, #48 +; CHECK-GI-NEXT: stp x20, x19, [sp, #16] ; 16-byte Folded Spill +; CHECK-GI-NEXT: stp x29, x30, [sp, #32] ; 16-byte Folded Spill +; CHECK-GI-NEXT: .cfi_def_cfa_offset 48 ; CHECK-GI-NEXT: .cfi_offset w30, -8 ; CHECK-GI-NEXT: .cfi_offset w29, -16 ; CHECK-GI-NEXT: .cfi_offset w19, -24 @@ -167,19 +170,20 @@ define dso_local void @rv_marker_3() personality ptr @__gxx_personality_v0 { ; CHECK-GI-NEXT: mov x0, x19 ; CHECK-GI-NEXT: Lloh1: ; CHECK-GI-NEXT: ldr x1, [x1, _objc_release@GOTPAGEOFF] -; CHECK-GI-NEXT: ldp x29, x30, [sp, #16] ; 16-byte Folded Reload -; CHECK-GI-NEXT: ldp x20, x19, [sp], #32 ; 16-byte Folded Reload +; CHECK-GI-NEXT: ldp x29, x30, [sp, #32] ; 16-byte Folded Reload +; CHECK-GI-NEXT: ldp x20, x19, [sp, #16] ; 16-byte Folded Reload +; CHECK-GI-NEXT: add sp, sp, #48 ; CHECK-GI-NEXT: br x1 ; CHECK-GI-NEXT: LBB3_2: ; %lpad ; CHECK-GI-NEXT: Ltmp2: ; EH_LABEL ; CHECK-GI-NEXT: Lloh2: ; CHECK-GI-NEXT: adrp x8, _objc_release@GOTPAGE -; CHECK-GI-NEXT: mov x20, x0 -; CHECK-GI-NEXT: mov x0, x19 ; CHECK-GI-NEXT: Lloh3: ; CHECK-GI-NEXT: ldr x8, [x8, _objc_release@GOTPAGEOFF] +; CHECK-GI-NEXT: str x0, [sp, #8] ; 8-byte Spill +; CHECK-GI-NEXT: mov x0, x19 ; CHECK-GI-NEXT: blr x8 -; CHECK-GI-NEXT: mov x0, x20 +; CHECK-GI-NEXT: ldr x0, [sp, #8] ; 8-byte Reload ; CHECK-GI-NEXT: bl __Unwind_Resume ; CHECK-GI-NEXT: .loh AdrpLdrGot Lloh0, Lloh1 ; CHECK-GI-NEXT: .loh AdrpLdrGot Lloh2, Lloh3 @@ -260,18 +264,17 @@ define dso_local void @rv_marker_4() personality ptr @__gxx_personality_v0 { ; CHECK-SD-NEXT: ret ; CHECK-SD-NEXT: LBB4_3: ; %lpad1 ; CHECK-SD-NEXT: Ltmp8: ; EH_LABEL -; CHECK-SD-NEXT: mov x1, x19 -; CHECK-SD-NEXT: mov x19, x0 -; CHECK-SD-NEXT: mov x0, x1 +; CHECK-SD-NEXT: str x0, [sp] ; 8-byte Spill +; CHECK-SD-NEXT: mov x0, x19 ; CHECK-SD-NEXT: bl _objc_release ; CHECK-SD-NEXT: b LBB4_5 ; CHECK-SD-NEXT: LBB4_4: ; %lpad ; CHECK-SD-NEXT: Ltmp5: ; EH_LABEL -; CHECK-SD-NEXT: mov x19, x0 +; CHECK-SD-NEXT: str x0, [sp] ; 8-byte Spill ; CHECK-SD-NEXT: LBB4_5: ; %ehcleanup ; CHECK-SD-NEXT: add x0, sp, #15 ; CHECK-SD-NEXT: bl __ZN1SD1Ev -; CHECK-SD-NEXT: mov x0, x19 +; CHECK-SD-NEXT: ldr x0, [sp] ; 8-byte Reload ; CHECK-SD-NEXT: bl __Unwind_Resume ; CHECK-SD-NEXT: Lfunc_end1: ; CHECK-SD-NEXT: .cfi_endproc @@ -340,19 +343,19 @@ define dso_local void @rv_marker_4() personality ptr @__gxx_personality_v0 { ; CHECK-GI-NEXT: Ltmp8: ; EH_LABEL ; CHECK-GI-NEXT: Lloh6: ; CHECK-GI-NEXT: adrp x8, _objc_release@GOTPAGE -; CHECK-GI-NEXT: mov x20, x0 -; CHECK-GI-NEXT: mov x0, x19 ; CHECK-GI-NEXT: Lloh7: ; CHECK-GI-NEXT: ldr x8, [x8, _objc_release@GOTPAGEOFF] +; CHECK-GI-NEXT: str x0, [sp] ; 8-byte Spill +; CHECK-GI-NEXT: mov x0, x19 ; CHECK-GI-NEXT: blr x8 ; CHECK-GI-NEXT: b LBB4_5 ; CHECK-GI-NEXT: LBB4_4: ; %lpad ; CHECK-GI-NEXT: Ltmp5: ; EH_LABEL -; CHECK-GI-NEXT: mov x20, x0 +; CHECK-GI-NEXT: str x0, [sp] ; 8-byte Spill ; CHECK-GI-NEXT: LBB4_5: ; %ehcleanup ; CHECK-GI-NEXT: add x0, sp, #15 ; CHECK-GI-NEXT: bl __ZN1SD1Ev -; CHECK-GI-NEXT: mov x0, x20 +; CHECK-GI-NEXT: ldr x0, [sp] ; 8-byte Reload ; CHECK-GI-NEXT: bl __Unwind_Resume ; CHECK-GI-NEXT: .loh AdrpLdrGot Lloh4, Lloh5 ; CHECK-GI-NEXT: .loh AdrpLdrGot Lloh6, Lloh7 diff --git a/llvm/test/CodeGen/AArch64/sme-za-exceptions.ll b/llvm/test/CodeGen/AArch64/sme-za-exceptions.ll index c353a3e6496a8..a48c3e5e9b5c2 100644 --- a/llvm/test/CodeGen/AArch64/sme-za-exceptions.ll +++ b/llvm/test/CodeGen/AArch64/sme-za-exceptions.ll @@ -29,14 +29,12 @@ define void @za_with_raii(i1 %fail) "aarch64_inout_za" personality ptr @__gxx_pe ; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0 ; CHECK-NEXT: .cfi_lsda 28, .Lexception0 ; CHECK-NEXT: // %bb.0: -; CHECK-NEXT: stp x29, x30, [sp, #-32]! // 16-byte Folded Spill -; CHECK-NEXT: str x19, [sp, #16] // 8-byte Spill +; CHECK-NEXT: stp x29, x30, [sp, #-16]! // 16-byte Folded Spill ; CHECK-NEXT: mov x29, sp -; CHECK-NEXT: sub sp, sp, #16 -; CHECK-NEXT: .cfi_def_cfa w29, 32 -; CHECK-NEXT: .cfi_offset w19, -16 -; CHECK-NEXT: .cfi_offset w30, -24 -; CHECK-NEXT: .cfi_offset w29, -32 +; CHECK-NEXT: sub sp, sp, #32 +; CHECK-NEXT: .cfi_def_cfa w29, 16 +; CHECK-NEXT: .cfi_offset w30, -8 +; CHECK-NEXT: .cfi_offset w29, -16 ; CHECK-NEXT: rdsvl x8, #1 ; CHECK-NEXT: mov x9, sp ; CHECK-NEXT: msub x9, x8, x8, x9 @@ -45,8 +43,7 @@ define void @za_with_raii(i1 %fail) "aarch64_inout_za" personality ptr @__gxx_pe ; CHECK-NEXT: tbnz w0, #0, .LBB0_2 ; CHECK-NEXT: // %bb.1: // %return_normally ; CHECK-NEXT: mov sp, x29 -; CHECK-NEXT: ldr x19, [sp, #16] // 8-byte Reload -; CHECK-NEXT: ldp x29, x30, [sp], #32 // 16-byte Folded Reload +; CHECK-NEXT: ldp x29, x30, [sp], #16 // 16-byte Folded Reload ; CHECK-NEXT: b shared_za_call ; CHECK-NEXT: .LBB0_2: // %throw_exception ; CHECK-NEXT: sub x8, x29, #16 @@ -73,7 +70,7 @@ define void @za_with_raii(i1 %fail) "aarch64_inout_za" personality ptr @__gxx_pe ; CHECK-NEXT: // %bb.5: // %throw_fail ; CHECK-NEXT: .LBB0_6: // %unwind_dtors ; CHECK-NEXT: .Ltmp2: // EH_LABEL -; CHECK-NEXT: mov x19, x0 +; CHECK-NEXT: stur x0, [x29, #-24] // 8-byte Folded Spill ; CHECK-NEXT: smstart za ; CHECK-NEXT: mrs x8, TPIDR2_EL0 ; CHECK-NEXT: sub x0, x29, #16 @@ -84,8 +81,8 @@ define void @za_with_raii(i1 %fail) "aarch64_inout_za" personality ptr @__gxx_pe ; CHECK-NEXT: msr TPIDR2_EL0, xzr ; CHECK-NEXT: bl shared_za_call ; CHECK-NEXT: sub x8, x29, #16 -; CHECK-NEXT: mov x0, x19 ; CHECK-NEXT: msr TPIDR2_EL0, x8 +; CHECK-NEXT: ldur x0, [x29, #-24] // 8-byte Folded Reload ; CHECK-NEXT: bl _Unwind_Resume br i1 %fail, label %throw_exception, label %return_normally @@ -306,13 +303,13 @@ define void @try_catch_shared_zt0_callee() "aarch64_inout_zt0" personality ptr @ ; CHECK-NEXT: .cfi_personality 156, DW.ref.__gxx_personality_v0 ; CHECK-NEXT: .cfi_lsda 28, .Lexception3 ; CHECK-NEXT: // %bb.0: -; CHECK-NEXT: sub sp, sp, #80 -; CHECK-NEXT: stp x30, x19, [sp, #64] // 16-byte Folded Spill -; CHECK-NEXT: .cfi_def_cfa_offset 80 +; CHECK-NEXT: sub sp, sp, #96 +; CHECK-NEXT: stp x30, x19, [sp, #80] // 16-byte Folded Spill +; CHECK-NEXT: .cfi_def_cfa_offset 96 ; CHECK-NEXT: .cfi_offset w19, -8 ; CHECK-NEXT: .cfi_offset w30, -16 ; CHECK-NEXT: .Ltmp9: // EH_LABEL -; CHECK-NEXT: mov x19, sp +; CHECK-NEXT: add x19, sp, #16 ; CHECK-NEXT: str zt0, [x19] ; CHECK-NEXT: smstop za ; CHECK-NEXT: bl may_throw @@ -320,20 +317,18 @@ define void @try_catch_shared_zt0_callee() "aarch64_inout_zt0" personality ptr @ ; CHECK-NEXT: smstart za ; CHECK-NEXT: ldr zt0, [x19] ; CHECK-NEXT: // %bb.1: // %return_normally -; CHECK-NEXT: ldp x30, x19, [sp, #64] // 16-byte Folded Reload -; CHECK-NEXT: add sp, sp, #80 +; CHECK-NEXT: ldp x30, x19, [sp, #80] // 16-byte Folded Reload +; CHECK-NEXT: add sp, sp, #96 ; CHECK-NEXT: ret ; CHECK-NEXT: .LBB3_2: // %unwind_dtors ; CHECK-NEXT: .Ltmp11: // EH... [truncated] `````````` </details> https://github.com/llvm/llvm-project/pull/239530 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
