diff options
author | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2020-12-10 18:05:51 -0600 |
---|---|---|
committer | Jonas Paulsson <paulsson@linux.vnet.ibm.com> | 2020-12-10 18:05:51 -0600 |
commit | bc7a61b7036044636f9a2c91c916153532a551f8 (patch) | |
tree | 868680d5f6dd5dab39ad9c897e27a7b407fd4783 /llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp | |
parent | eaa9f6b2cca82819dfa2f60fc878ead80c4138b5 (diff) | |
download | llvm-bc7a61b7036044636f9a2c91c916153532a551f8.zip llvm-bc7a61b7036044636f9a2c91c916153532a551f8.tar.gz llvm-bc7a61b7036044636f9a2c91c916153532a551f8.tar.bz2 |
Revert "[SystemZFrameLowering] Don't overrwrite R1D (backchain) when probing."
Temporarily reverted.
This reverts commit ea475c77ff9eab1de7d44684c8fb453b39f70081.
Diffstat (limited to 'llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp')
-rw-r--r-- | llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp | 52 |
1 files changed, 21 insertions, 31 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp index 0bfab12..57529c8 100644 --- a/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp +++ b/llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp @@ -488,6 +488,15 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF, MFFrame.setStackSize(StackSize); if (StackSize) { + // Determine if we want to store a backchain. + bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain"); + + // If we need backchain, save current stack pointer. R1 is free at this + // point. + if (StoreBackchain) + BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR)) + .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D); + // Allocate StackSize bytes. int64_t Delta = -int64_t(StackSize); const unsigned ProbeSize = TLI.getStackProbeSize(MF); @@ -503,23 +512,18 @@ void SystemZFrameLowering::emitPrologue(MachineFunction &MF, .addImm(StackSize); } else { - bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain"); - // If we need backchain, save current stack pointer. R1 is free at - // this point. - if (StoreBackchain) - BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::LGR)) - .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D); emitIncrement(MBB, MBBI, DL, SystemZ::R15D, Delta, ZII); buildCFAOffs(MBB, MBBI, DL, SPOffsetFromCFA + Delta, ZII); - if (StoreBackchain) { - // The back chain is stored topmost with packed-stack. - int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0; - BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG)) - .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D) - .addImm(Offset).addReg(0); - } } SPOffsetFromCFA += Delta; + + if (StoreBackchain) { + // The back chain is stored topmost with packed-stack. + int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0; + BuildMI(MBB, MBBI, DL, ZII->get(SystemZ::STG)) + .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D) + .addImm(Offset).addReg(0); + } } if (HasFP) { @@ -664,11 +668,6 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction &MF, .addMemOperand(MMO); }; - bool StoreBackchain = MF.getFunction().hasFnAttribute("backchain"); - if (StoreBackchain) - BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR)) - .addReg(SystemZ::R1D, RegState::Define).addReg(SystemZ::R15D); - if (NumFullBlocks < 3) { // Emit unrolled probe statements. for (unsigned int i = 0; i < NumFullBlocks; i++) @@ -678,11 +677,10 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction &MF, uint64_t LoopAlloc = ProbeSize * NumFullBlocks; SPOffsetFromCFA -= LoopAlloc; - // Use R0D to hold the exit value. - BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R0D) + BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::LGR), SystemZ::R1D) .addReg(SystemZ::R15D); - buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R0D, ZII); - emitIncrement(*MBB, MBBI, DL, SystemZ::R0D, -int64_t(LoopAlloc), ZII); + buildDefCFAReg(*MBB, MBBI, DL, SystemZ::R1D, ZII); + emitIncrement(*MBB, MBBI, DL, SystemZ::R1D, -int64_t(LoopAlloc), ZII); buildCFAOffs(*MBB, MBBI, DL, -int64_t(SystemZMC::CallFrameSize + LoopAlloc), ZII); @@ -695,7 +693,7 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction &MF, MBB = LoopMBB; allocateAndProbe(*MBB, MBB->end(), ProbeSize, false/*EmitCFI*/); BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::CLGR)) - .addReg(SystemZ::R15D).addReg(SystemZ::R0D); + .addReg(SystemZ::R15D).addReg(SystemZ::R1D); BuildMI(*MBB, MBB->end(), DL, ZII->get(SystemZ::BRC)) .addImm(SystemZ::CCMASK_ICMP).addImm(SystemZ::CCMASK_CMP_GT).addMBB(MBB); @@ -710,14 +708,6 @@ void SystemZFrameLowering::inlineStackProbe(MachineFunction &MF, if (Residual) allocateAndProbe(*MBB, MBBI, Residual, true/*EmitCFI*/); - if (StoreBackchain) { - // The back chain is stored topmost with packed-stack. - int Offset = usePackedStack(MF) ? SystemZMC::CallFrameSize - 8 : 0; - BuildMI(*MBB, MBBI, DL, ZII->get(SystemZ::STG)) - .addReg(SystemZ::R1D, RegState::Kill).addReg(SystemZ::R15D) - .addImm(Offset).addReg(0); - } - StackAllocMI->eraseFromParent(); } |