diff --git a/llvm/include/llvm/CodeGen/StackMaps.h b/llvm/include/llvm/CodeGen/StackMaps.h --- a/llvm/include/llvm/CodeGen/StackMaps.h +++ b/llvm/include/llvm/CodeGen/StackMaps.h @@ -243,6 +243,14 @@ unsigned getGCPointerMap(SmallVectorImpl> &GCMap); + /// Return true if Reg is used only in operands which can be folded to + /// stack usage. + bool isFoldableReg(Register Reg) const; + + /// Return true if Reg is used only in operands of MI which can be folded to + /// stack usage and MI is a statepoint instruction. + static bool isFoldableReg(const MachineInstr *MI, Register Reg); + private: const MachineInstr *MI; unsigned NumDefs; diff --git a/llvm/lib/CodeGen/InlineSpiller.cpp b/llvm/lib/CodeGen/InlineSpiller.cpp --- a/llvm/lib/CodeGen/InlineSpiller.cpp +++ b/llvm/lib/CodeGen/InlineSpiller.cpp @@ -280,13 +280,28 @@ Register Reg = Edit->getReg(); // A snippet is a tiny live range with only a single instruction using it - // besides copies to/from Reg or spills/fills. We accept: + // besides copies to/from Reg or spills/fills. + // Exception is done for statepoint instructions which will fold fills + // into their operands. + // We accept: // // %snip = COPY %Reg / FILL fi# // %snip = USE %snip + // %snip = STATEPOINT %snip in var arg area // %Reg = COPY %snip / SPILL %snip, fi# // - if (SnipLI.getNumValNums() > 2 || !LIS.intervalIsInOneMBB(SnipLI)) + if (!LIS.intervalIsInOneMBB(SnipLI)) + return false; + + // Number of defs should not exceed 2 not accounting defs coming from + // statepoint instructions. + unsigned NumValNums = SnipLI.getNumValNums(); + for (auto *VNI : SnipLI.vnis()) { + MachineInstr *MI = LIS.getInstructionFromIndex(VNI->def); + if (MI->getOpcode() == TargetOpcode::STATEPOINT) + --NumValNums; + } + if (NumValNums > 2) return false; MachineInstr *UseMI = nullptr; @@ -311,6 +326,9 @@ if (SnipLI.reg() == TII.isStoreToStackSlot(MI, FI) && FI == StackSlot) continue; + if (StatepointOpers::isFoldableReg(&MI, SnipLI.reg())) + continue; + // Allow a single additional instruction. if (UseMI && &MI != UseMI) return false; diff --git a/llvm/lib/CodeGen/StackMaps.cpp b/llvm/lib/CodeGen/StackMaps.cpp --- a/llvm/lib/CodeGen/StackMaps.cpp +++ b/llvm/lib/CodeGen/StackMaps.cpp @@ -146,6 +146,23 @@ return GCMapSize; } +bool StatepointOpers::isFoldableReg(Register Reg) const { + unsigned FoldableAreaStart = getVarIdx(); + for (const MachineOperand &MO : MI->uses()) { + if (MI->getOperandNo(&MO) >= FoldableAreaStart) + break; + if (MO.isReg() && MO.getReg() == Reg) + return false; + } + return true; +} + +bool StatepointOpers::isFoldableReg(const MachineInstr *MI, Register Reg) { + if (MI->getOpcode() != TargetOpcode::STATEPOINT) + return false; + return StatepointOpers(MI).isFoldableReg(Reg); +} + StackMaps::StackMaps(AsmPrinter &AP) : AP(AP) { if (StackMapVersion != 3) llvm_unreachable("Unsupported stackmap version!"); diff --git a/llvm/test/CodeGen/AArch64/regalloc-last-chance-recolor-with-split.mir b/llvm/test/CodeGen/AArch64/regalloc-last-chance-recolor-with-split.mir --- a/llvm/test/CodeGen/AArch64/regalloc-last-chance-recolor-with-split.mir +++ b/llvm/test/CodeGen/AArch64/regalloc-last-chance-recolor-with-split.mir @@ -271,31 +271,30 @@ ; CHECK-NEXT: successors: %bb.1(0x80000000), %bb.2(0x00000000) ; CHECK-NEXT: liveins: $x0 ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: renamable $x19 = COPY $x0 + ; CHECK-NEXT: STRXui $x0, %stack.0, 0 :: (store (s64) into %stack.0) ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: dead $w1 = MOVi32imm 526, implicit-def $x1 ; CHECK-NEXT: dead $w2 = MOVi32imm 2, implicit-def $x2 - ; CHECK-NEXT: renamable $w21 = MOVi32imm 2, implicit-def $x21 - ; CHECK-NEXT: renamable $x19 = STATEPOINT 2882400000, 0, 4, @bar, undef $x0, $x1, $x2, undef $x3, 2, 0, 2, 4, 2, 39, 2, 0, 2, 1, 2, 0, 2, 42, 2, 2, 2, 14, 2, 0, 2, 3, 2, 400, 2, 3, 2, 400, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 7, 2, 0, 2, 7, 2, 0, 2, 1, renamable $x19(tied-def 0), 2, 0, 2, 1, 0, 0, csr_aarch64_aapcs, implicit-def $sp, implicit-def $x0, implicit-def dead early-clobber $lr + ; CHECK-NEXT: renamable $w19 = MOVi32imm 2, implicit-def $x19 + ; CHECK-NEXT: STATEPOINT 2882400000, 0, 4, @bar, undef $x0, $x1, $x2, undef $x3, 2, 0, 2, 4, 2, 39, 2, 0, 2, 1, 2, 0, 2, 42, 2, 2, 2, 14, 2, 0, 2, 3, 2, 400, 2, 3, 2, 400, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 7, 2, 0, 2, 7, 2, 0, 2, 1, 1, 8, %stack.0, 0, 2, 0, 2, 1, 0, 0, csr_aarch64_aapcs, implicit-def $sp, implicit-def $x0, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: renamable $x20 = COPY $x0 ; CHECK-NEXT: DMB 11 ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: renamable $x20, renamable $x19 = STATEPOINT 2, 4, 1, undef renamable $x0, undef $x0, 2, 0, 2, 4, 2, 35, 2, 0, 2, 2, 2, 0, 2, 48, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, renamable $x20(tied-def 0), renamable $x19(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $x0, implicit-def dead early-clobber $lr + ; CHECK-NEXT: renamable $x20 = STATEPOINT 2, 4, 1, undef renamable $x0, undef $x0, 2, 0, 2, 4, 2, 35, 2, 0, 2, 2, 2, 0, 2, 48, 2, 0, 2, 14, 2, 0, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, renamable $x20(tied-def 0), 1, 8, %stack.0, 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $x0, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: $w1 = MOVi32imm 33333 - ; CHECK-NEXT: renamable $x20, renamable $x19 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, $w1, 2, 0, 2, 0, 2, 41, 2, 0, 2, 2, 2, 0, 2, 73, 2, 3, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, 2, 4278124286, 2, 0, 2, 4278124286, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 3, renamable $x20(tied-def 0), renamable $x19(tied-def 1), 2, 4278124286, 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr + ; CHECK-NEXT: renamable $x20 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, $w1, 2, 0, 2, 0, 2, 41, 2, 0, 2, 2, 2, 0, 2, 73, 2, 3, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, 2, 4278124286, 2, 0, 2, 4278124286, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 3, renamable $x20(tied-def 0), 1, 8, %stack.0, 0, 2, 4278124286, 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: renamable $x20, renamable $x19 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, undef $w1, 2, 0, 2, 0, 2, 39, 2, 0, 2, 2, 2, 0, 2, 78, 2, 2, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, 2, 4278124286, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 3, renamable $x20(tied-def 0), renamable $x19(tied-def 1), 2, 4278124286, 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr + ; CHECK-NEXT: renamable $x20 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, undef $w1, 2, 0, 2, 0, 2, 39, 2, 0, 2, 2, 2, 0, 2, 78, 2, 2, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, 2, 4278124286, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 3, renamable $x20(tied-def 0), 1, 8, %stack.0, 0, 2, 4278124286, 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: renamable $x20, renamable $x19 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, undef $w1, 2, 0, 2, 0, 2, 37, 2, 0, 2, 2, 2, 0, 2, 83, 2, 1, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, renamable $x20(tied-def 0), renamable $x19(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr + ; CHECK-NEXT: renamable $x20 = STATEPOINT 2, 4, 2, undef renamable $x0, undef $x0, undef $w1, 2, 0, 2, 0, 2, 37, 2, 0, 2, 2, 2, 0, 2, 83, 2, 1, 2, 14, 2, 0, 2, 3, 2, 95, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, renamable $x20(tied-def 0), 1, 8, %stack.0, 0, 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead $w0, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: renamable $x19, dead renamable $x20 = STATEPOINT 2, 4, 1, undef renamable $x0, undef $w0, 2, 0, 2, 0, 2, 35, 2, 0, 2, 2, 2, 0, 2, 95, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, renamable $x19(tied-def 0), renamable $x20(tied-def 1), 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr - ; CHECK-NEXT: STRXui killed renamable $x19, %stack.0, 0 :: (store (s64) into %stack.0) + ; CHECK-NEXT: dead renamable $x20 = STATEPOINT 2, 4, 1, undef renamable $x0, undef $w0, 2, 0, 2, 0, 2, 35, 2, 0, 2, 2, 2, 0, 2, 95, 2, 0, 2, 14, 2, 0, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 3, 2, 95, 2, 7, 2, 0, 2, 3, 2, -11, 2, 3, 2, -8280, 2, 3, 2, 45, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 2, 1, 8, %stack.0, 0, renamable $x20(tied-def 0), 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: CBNZW $wzr, %bb.2 ; CHECK-NEXT: B %bb.1 @@ -303,11 +302,11 @@ ; CHECK-NEXT: bb.1.bb27.preheader: ; CHECK-NEXT: successors: %bb.3(0x80000000) ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: renamable $x24 = LDRXui undef renamable $x8, 0 :: (load unordered (s64) from `ptr addrspace(1) undef`, addrspace 1) + ; CHECK-NEXT: renamable $x20 = LDRXui undef renamable $x8, 0 :: (load unordered (s64) from `ptr addrspace(1) undef`, addrspace 1) ; CHECK-NEXT: renamable $w21 = MOVi32imm -8280 ; CHECK-NEXT: renamable $w23 = MOVi32imm -6 ; CHECK-NEXT: renamable $w25 = MOVi32imm 3, implicit-def $x25 - ; CHECK-NEXT: renamable $w20 = MOVi32imm 2143289344 + ; CHECK-NEXT: renamable $w24 = MOVi32imm 2143289344 ; CHECK-NEXT: renamable $x22 = IMPLICIT_DEF ; CHECK-NEXT: dead renamable $x8 = IMPLICIT_DEF ; CHECK-NEXT: renamable $x26 = IMPLICIT_DEF @@ -322,16 +321,16 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.2.bb23: ; CHECK-NEXT: successors: - ; CHECK-NEXT: liveins: $x21 + ; CHECK-NEXT: liveins: $x19 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: renamable $w19 = MOVi32imm 95 - ; CHECK-NEXT: STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 39, 2, 0, 2, 1, 2, 0, 2, 117, 2, 2, 2, 14, 2, 0, 2, 3, 2, 3, 2, 3, 2, 109, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 3, killed renamable $w19, 2, 3, renamable $w21, 2, 3, 2, 3, 2, 3, 2, -8280, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, 2, 4278124286, 2, 7, 2, 0, 2, 2, 1, 8, %stack.0, 0, 2, 4278124286, 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x21 :: (load store (s64) on %stack.0) + ; CHECK-NEXT: renamable $w20 = MOVi32imm 95 + ; CHECK-NEXT: STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 39, 2, 0, 2, 1, 2, 0, 2, 117, 2, 2, 2, 14, 2, 0, 2, 3, 2, 3, 2, 3, 2, 109, 2, 0, 1, 8, %stack.0, 0, 2, 7, 2, 0, 2, 3, killed renamable $w20, 2, 3, renamable $w19, 2, 3, 2, 3, 2, 3, 2, -8280, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 5, 2, 7, 2, 0, 2, 3, 2, 1, 2, 0, 2, 4278124286, 2, 7, 2, 0, 2, 2, 1, 8, %stack.0, 0, 2, 4278124286, 2, 0, 2, 2, 0, 0, 1, 1, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x19 :: (load store (s64) on %stack.0) ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.3.bb27: ; CHECK-NEXT: successors: %bb.4(0x80000000), %bb.13(0x00000000) - ; CHECK-NEXT: liveins: $w20, $w21, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $w21, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: renamable $fp = nuw nsw ADDXri renamable $x25, 1, 0 ; CHECK-NEXT: CBNZW $wzr, %bb.13 @@ -339,32 +338,30 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.4.bb41: ; CHECK-NEXT: successors: %bb.5(0x7ffff777), %bb.6(0x00000889) - ; CHECK-NEXT: liveins: $fp, $w20, $w21, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w21, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: CBZW $wzr, %bb.6 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.5: ; CHECK-NEXT: successors: %bb.7(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: B %bb.7 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.6.bb42: ; CHECK-NEXT: successors: %bb.7(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w21, $w23, $x24, $x25, $x27 + ; CHECK-NEXT: liveins: $fp, $w21, $w23, $w24, $x20, $x25, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: renamable $x19 = LDRXui %stack.0, 0 :: (load (s64) from %stack.0) + ; CHECK-NEXT: renamable $w22 = MOVi32imm 2, implicit-def $x22 ; CHECK-NEXT: renamable $w26 = MOVi32imm 95 - ; CHECK-NEXT: renamable $x22 = LDRXui %stack.1, 0 :: (load (s64) from %stack.1) - ; CHECK-NEXT: renamable $w20 = MOVi32imm 2, implicit-def $x20 - ; CHECK-NEXT: renamable $x27, renamable $x22, dead renamable $x19 = STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 35, 2, 0, 2, 1, 2, 0, 2, 125, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, killed renamable $w26, 2, 3, renamable $w20, 2, 3, 2, 4278124286, 2, 3, killed renamable $w21, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 2, 2, 7, 2, 0, 2, 3, 2, 4278124286, 2, 0, killed renamable $x22, 2, 7, 2, 0, 2, 3, killed renamable $x27(tied-def 0), renamable $x22(tied-def 1), renamable $x19(tied-def 2), 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x20 - ; CHECK-NEXT: renamable $w20 = MOVi32imm 2143289344 + ; CHECK-NEXT: renamable $x27, dead renamable $x19 = STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 35, 2, 0, 2, 1, 2, 0, 2, 125, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, killed renamable $w26, 2, 3, renamable $w22, 2, 3, 2, 4278124286, 2, 3, killed renamable $w21, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 2, 2, 7, 2, 0, 2, 3, 2, 4278124286, 2, 0, 1, 8, %stack.1, 0, 2, 7, 2, 0, 2, 3, killed renamable $x27(tied-def 0), 1, 8, %stack.1, 0, renamable $x19(tied-def 1), 2, 0, 2, 3, 0, 0, 1, 1, 2, 2, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x22 :: (load store (s64) on %stack.1) ; CHECK-NEXT: renamable $w10 = MOVi32imm 2, implicit-def $x10 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: renamable $x19 = COPY $xzr - ; CHECK-NEXT: STRXui renamable $x22, %stack.1, 0 :: (store (s64) into %stack.1) - ; CHECK-NEXT: dead renamable $x8 = nuw ADDXri killed renamable $x22, 24, 0 + ; CHECK-NEXT: renamable $x8 = LDRXui %stack.1, 0 :: (load (s64) from %stack.1) + ; CHECK-NEXT: dead renamable $x8 = nuw ADDXri killed renamable $x8, 24, 0 ; CHECK-NEXT: renamable $x22 = IMPLICIT_DEF ; CHECK-NEXT: renamable $x26 = IMPLICIT_DEF ; CHECK-NEXT: renamable $x8 = IMPLICIT_DEF @@ -372,19 +369,19 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.7.bb48: ; CHECK-NEXT: successors: %bb.8(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.8.bb79: ; CHECK-NEXT: successors: %bb.9(0x04000000), %bb.8(0x7c000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: CBNZW $wzr, %bb.8 ; CHECK-NEXT: B %bb.9 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.9.bb81: ; CHECK-NEXT: successors: %bb.11(0x78787f1d), %bb.10(0x078780e3) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: STRXui $xzr, renamable $x22, 0 :: (store unordered (s64), addrspace 1) ; CHECK-NEXT: CBNZW $wzr, %bb.11 @@ -392,7 +389,7 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.10.bb82: ; CHECK-NEXT: successors: %bb.11(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: BL @blam.1, csr_aarch64_aapcs, implicit-def dead $lr, implicit $sp, implicit-def $sp @@ -401,13 +398,13 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.11.bb83: ; CHECK-NEXT: successors: %bb.12(0x7ffff777), %bb.17(0x00000889) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: CBZW $wzr, %bb.17 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.12: ; CHECK-NEXT: successors: %bb.18(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: B %bb.18 ; CHECK-NEXT: {{ $}} @@ -427,7 +424,7 @@ ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.15.bb90: - ; CHECK-NEXT: successors: + ; CHECK-NEXT: successors:{{ $}} ; CHECK-NEXT: liveins: $fp, $w21, $x10 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp @@ -446,37 +443,34 @@ ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.17.bb96: ; CHECK-NEXT: successors: %bb.18(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w23, $x24, $x25, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x20, $x25, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: ADJCALLSTACKDOWN 0, 0, implicit-def dead $sp, implicit $sp ; CHECK-NEXT: renamable $x19 = LDRXui %stack.0, 0 :: (load (s64) from %stack.0) ; CHECK-NEXT: renamable $w21 = MOVi32imm 2, implicit-def $x21 ; CHECK-NEXT: renamable $w22 = MOVi32imm 95 - ; CHECK-NEXT: renamable $x20 = LDRXui %stack.1, 0 :: (load (s64) from %stack.1) - ; CHECK-NEXT: renamable $x26 = LDRXui %stack.2, 0 :: (load (s64) from %stack.2) - ; CHECK-NEXT: renamable $x26, renamable $x27, renamable $x20, dead renamable $x19 = STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 35, 2, 0, 2, 1, 2, 0, 2, 250, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, killed renamable $w22, 2, 3, renamable $w21, 2, 3, 2, 4278124286, 2, 3, renamable $w21, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 0, 2, 7, 2, 0, 2, 3, 2, 4278124286, 2, 0, killed renamable $x20, 2, 7, 2, 0, 2, 4, killed renamable $x26(tied-def 0), killed renamable $x27(tied-def 1), renamable $x20(tied-def 2), renamable $x19(tied-def 3), 2, 0, 2, 4, 0, 0, 1, 1, 2, 2, 3, 3, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x21 + ; CHECK-NEXT: renamable $x27, dead renamable $x19 = STATEPOINT 2882400000, 0, 0, @wombat, 2, 0, 2, 0, 2, 35, 2, 0, 2, 1, 2, 0, 2, 250, 2, 0, 2, 14, 2, 0, 2, 0, killed renamable $x19, 2, 7, 2, 0, 2, 3, killed renamable $w22, 2, 3, renamable $w21, 2, 3, 2, 4278124286, 2, 3, renamable $w21, 2, 7, 2, 0, 2, 3, 2, 230, 2, 7, 2, 0, 2, 4, 2, 0, 2, 7, 2, 0, 2, 3, 2, 4278124286, 2, 0, 1, 8, %stack.1, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.2, 0, killed renamable $x27(tied-def 0), 1, 8, %stack.1, 0, renamable $x19(tied-def 1), 2, 0, 2, 4, 0, 0, 1, 1, 2, 2, 3, 3, csr_aarch64_aapcs, implicit-def $sp, implicit-def dead early-clobber $lr, implicit killed $x21 :: (load store (s64) on %stack.1), (load store (s64) on %stack.2) ; CHECK-NEXT: renamable $w10 = MOVi32imm 2, implicit-def $x10 ; CHECK-NEXT: ADJCALLSTACKUP 0, 0, implicit-def dead $sp, implicit $sp - ; CHECK-NEXT: STRXui renamable $x20, %stack.1, 0 :: (store (s64) into %stack.1) - ; CHECK-NEXT: dead renamable $x8 = nuw ADDXri killed renamable $x20, 24, 0 - ; CHECK-NEXT: renamable $w20 = MOVi32imm 2143289344 - ; CHECK-NEXT: STRXui renamable $x26, %stack.2, 0 :: (store (s64) into %stack.2) - ; CHECK-NEXT: renamable $x22 = nuw ADDXri killed renamable $x26, 848, 0 + ; CHECK-NEXT: renamable $x8 = LDRXui %stack.1, 0 :: (load (s64) from %stack.1) + ; CHECK-NEXT: dead renamable $x8 = nuw ADDXri killed renamable $x8, 24, 0 + ; CHECK-NEXT: renamable $x8 = LDRXui %stack.2, 0 :: (load (s64) from %stack.2) + ; CHECK-NEXT: renamable $x22 = nuw ADDXri killed renamable $x8, 848, 0 ; CHECK-NEXT: renamable $x26 = IMPLICIT_DEF ; CHECK-NEXT: renamable $x19 = IMPLICIT_DEF ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.18.bb105: ; CHECK-NEXT: successors: %bb.20(0x00000000), %bb.19(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} - ; CHECK-NEXT: STRWui renamable $w24, renamable $x19, 0 :: (store unordered (s32), addrspace 1) - ; CHECK-NEXT: STRWui renamable $w20, renamable $x26, 0 :: (store unordered (s32), align 8, addrspace 1) + ; CHECK-NEXT: STRWui renamable $w20, renamable $x19, 0 :: (store unordered (s32), addrspace 1) + ; CHECK-NEXT: STRWui renamable $w24, renamable $x26, 0 :: (store unordered (s32), align 8, addrspace 1) ; CHECK-NEXT: CBZX renamable $x27, %bb.20 ; CHECK-NEXT: B %bb.19 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: bb.19.bb115: ; CHECK-NEXT: successors: %bb.16(0x00000000), %bb.3(0x80000000) - ; CHECK-NEXT: liveins: $fp, $w20, $w23, $x10, $x19, $x22, $x24, $x25, $x26, $x27 + ; CHECK-NEXT: liveins: $fp, $w23, $w24, $x10, $x19, $x20, $x22, $x25, $x26, $x27 ; CHECK-NEXT: {{ $}} ; CHECK-NEXT: renamable $x8 = COPY $xzr ; CHECK-NEXT: renamable $w9 = LDRWui renamable $x8, 0 :: (load unordered (s32) from `ptr addrspace(1) null`, addrspace 1) diff --git a/llvm/test/CodeGen/X86/statepoint-ra.ll b/llvm/test/CodeGen/X86/statepoint-ra.ll --- a/llvm/test/CodeGen/X86/statepoint-ra.ll +++ b/llvm/test/CodeGen/X86/statepoint-ra.ll @@ -132,8 +132,8 @@ ;CHECK: bb.5.bb21: ;CHECK: successors: ;CHECK: ADJCALLSTACKDOWN64 8, 0, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp -;CHECK: %81:fr64 = MOVSDrm_alt %stack.7, 1, $noreg, 0, $noreg :: (load (s64) from %stack.7) -;CHECK: MOVSDmr $rsp, 1, $noreg, 0, $noreg, %81 :: (store (s64) into stack) +;CHECK: %79:fr64 = MOVSDrm_alt %stack.7, 1, $noreg, 0, $noreg :: (load (s64) from %stack.7) +;CHECK: MOVSDmr $rsp, 1, $noreg, 0, $noreg, %79 :: (store (s64) into stack) ;CHECK: $xmm0 = MOVSDrm_alt %stack.6, 1, $noreg, 0, $noreg :: (load (s64) from %stack.6) ;CHECK: $xmm1 = MOVSDrm_alt %stack.5, 1, $noreg, 0, $noreg :: (load (s64) from %stack.5) ;CHECK: $xmm2 = MOVSDrm_alt %stack.4, 1, $noreg, 0, $noreg :: (load (s64) from %stack.4) @@ -141,13 +141,11 @@ ;CHECK: $xmm4 = MOVSDrm_alt %stack.1, 1, $noreg, 0, $noreg :: (load (s64) from %stack.1) ;CHECK: $xmm5 = MOVSDrm_alt %stack.3, 1, $noreg, 0, $noreg :: (load (s64) from %stack.3) ;CHECK: %74:fr64 = MOVSDrm_alt %fixed-stack.3, 1, $noreg, 0, $noreg :: (load (s64) from %fixed-stack.3, align 16) -;CHECK: %95:fr64 = COPY %74 -;CHECK: $xmm6 = COPY %95 +;CHECK: $xmm6 = COPY %74 ;CHECK: $esi = MOV32ri 51 ;CHECK: %69:fr64 = MOVSDrm_alt %fixed-stack.2, 1, $noreg, 0, $noreg :: (load (s64) from %fixed-stack.2) -;CHECK: %97:fr64 = COPY %69 -;CHECK: $xmm7 = COPY %97 -;CHECK: STATEPOINT 2, 5, 10, undef %36:gr64, undef $rdi, $xmm0, $xmm1, $xmm2, $xmm3, $xmm4, $xmm5, $xmm6, $xmm7, killed $esi, 2, 0, 2, 0, 2, 105, 2, 0, 2, 2, 2, 0, 2, 97, 2, 0, 2, 26, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 2, 2, 2, 2, 46, 2, 0, 2, 20, 2, 0, 2, 0, 2, 4278124286, 2, 4, 1, 8, %stack.6, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.5, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.4, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.2, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.1, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.3, 0, 2, 7, 2, 0, 2, 4, 1, 8, %fixed-stack.3, 0, 2, 7, 2, 0, 2, 4, 1, 8, %fixed-stack.2, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.7, 0, 2, 7, 2, 0, 2, 3, 2, 51, 2, 1, 2, 4278124286, 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (load (s64) from %stack.7), (load (s64) from %stack.6), (load (s64) from %stack.5), (load (s64) from %stack.4), (load (s64) from %stack.2), (load (s64) from %stack.1), (load (s64) from %stack.3), (load (s64) from %fixed-stack.3, align 16), (load (s64) from %fixed-stack.2) +;CHECK: $xmm7 = COPY %69 +;CHECK: STATEPOINT 2, 5, 10, undef %36:gr64, undef $rdi, $xmm0, $xmm1, $xmm2, $xmm3, $xmm4, $xmm5, $xmm6, $xmm7, killed $esi, 2, 0, 2, 0, 2, 105, 2, 0, 2, 2, 2, 0, 2, 97, 2, 0, 2, 26, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 7, 2, 0, 2, 2, 2, 2, 2, 46, 2, 0, 2, 20, 2, 0, 2, 0, 2, 4278124286, 2, 4, 1, 8, %stack.6, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.5, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.4, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.2, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.1, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.3, 0, 2, 7, 2, 0, 2, 4, 1, 8, %fixed-stack.3, 0, 2, 7, 2, 0, 2, 4, 1, 8, %fixed-stack.2, 0, 2, 7, 2, 0, 2, 4, 1, 8, %stack.7, 0, 2, 7, 2, 0, 2, 3, 2, 51, 2, 1, 2, 4278124286, 2, 0, 2, 1, 0, 0, csr_64, implicit-def $rsp, implicit-def $ssp :: (load (s64) from %stack.1), (load (s64) from %stack.2), (load (s64) from %stack.3), (load (s64) from %stack.4), (load (s64) from %stack.5), (load (s64) from %stack.6), (load (s64) from %fixed-stack.2), (load (s64) from %fixed-stack.3, align 16), (load (s64) from %stack.7) ;CHECK: ADJCALLSTACKUP64 8, 0, implicit-def dead $rsp, implicit-def dead $eflags, implicit-def dead $ssp, implicit $rsp, implicit $ssp ;CHECK: bb.6.bb23 (landing-pad): ;CHECK: liveins: $rax, $rdx diff --git a/llvm/test/CodeGen/X86/statepoint-split-single-block.ll b/llvm/test/CodeGen/X86/statepoint-split-single-block.ll --- a/llvm/test/CodeGen/X86/statepoint-split-single-block.ll +++ b/llvm/test/CodeGen/X86/statepoint-split-single-block.ll @@ -34,11 +34,9 @@ ; CHECK-NEXT: movabsq $nocsr, %rax ; CHECK-NEXT: callq *%rax ; CHECK-NEXT: movabsq $bar, %rax -; CHECK-NEXT: movq (%rsp), %rbx # 8-byte Reload -; CHECK-NEXT: movq %rbx, %rdi -; CHECK-NEXT: callq *%rax +; CHECK-NEXT: movq (%rsp), %rdi # 8-byte Reload +; CHECK-NEXT: callq *%rax # 8-byte Folded Reload ; CHECK-NEXT: .Ltmp0: -; CHECK-NEXT: movq %rbx, (%rsp) # 8-byte Spill ; CHECK-NEXT: movabsq $nocsr, %rax ; CHECK-NEXT: callq *%rax ; CHECK-NEXT: movq (%rsp), %rax # 8-byte Reload