Skip to content

Commit 12ae89c

Browse files
committed
Just set to 0
1 parent fe89827 commit 12ae89c

File tree

4 files changed

+25
-9
lines changed

4 files changed

+25
-9
lines changed

llvm/lib/Target/SystemZ/SystemZFrameLowering.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,22 @@ SystemZFrameLowering::create(const SystemZSubtarget &STI) {
6666
return std::make_unique<SystemZELFFrameLowering>();
6767
}
6868

69+
MachineBasicBlock::iterator SystemZFrameLowering::eliminateCallFramePseudoInstr(
70+
MachineFunction &MF, MachineBasicBlock &MBB,
71+
MachineBasicBlock::iterator MI) const {
72+
switch (MI->getOpcode()) {
73+
case SystemZ::ADJCALLSTACKDOWN:
74+
case SystemZ::ADJCALLSTACKUP:
75+
assert(hasReservedCallFrame(MF) &&
76+
"ADJSTACKDOWN and ADJSTACKUP should be no-ops");
77+
return MBB.erase(MI);
78+
break;
79+
80+
default:
81+
llvm_unreachable("Unexpected call frame instruction");
82+
}
83+
}
84+
6985
namespace {
7086
struct SZFrameSortingObj {
7187
bool IsValid = false; // True if we care about this Object.

llvm/lib/Target/SystemZ/SystemZFrameLowering.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class SystemZFrameLowering : public TargetFrameLowering {
4141
}
4242

4343
bool hasReservedCallFrame(const MachineFunction &MF) const override;
44+
MachineBasicBlock::iterator
45+
eliminateCallFramePseudoInstr(MachineFunction &MF, MachineBasicBlock &MBB,
46+
MachineBasicBlock::iterator MI) const override;
4447
};
4548

4649
class SystemZELFFrameLowering : public SystemZFrameLowering {

llvm/lib/Target/SystemZ/SystemZISelLowering.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8107,16 +8107,18 @@ SystemZTargetLowering::emitAdjCallStack(MachineInstr &MI,
81078107
MachineBasicBlock *BB) const {
81088108
// Do the work of MachineFrameInfo::computeMaxCallFrameSize() early and
81098109
// remove these nodes. Given that these nodes start out as a glued sequence
8110-
// it seems best to remove them here after instruction selection and
8110+
// it seems best to handle them here after instruction selection and
81118111
// scheduling.
81128112
MachineFrameInfo &MFI = BB->getParent()->getFrameInfo();
81138113
uint32_t NumBytes = MI.getOperand(0).getImm();
81148114
if (NumBytes > MFI.getMaxCallFrameSize())
81158115
MFI.setMaxCallFrameSize(NumBytes);
81168116
MFI.setAdjustsStack(true);
81178117

8118-
// TODO: MI should be erased. For now, keep it around as it seems to help
8119-
// scheduling around calls slightly in general (fix MachineScheduler).
8118+
// Set the NumBytes value to 0 to avoid problems of maintaining the call
8119+
// frame size across CFG edges. TODO: MI could be erased, but it seems to
8120+
// help scheduling around calls slightly (fix MachineScheduler + handle the
8121+
// adjustsStack implication).
81208122
MI.getOperand(0).setImm(0);
81218123

81228124
return BB;

llvm/lib/Target/SystemZ/SystemZInstrInfo.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ static uint64_t allOnes(unsigned int Count) {
5959
void SystemZInstrInfo::anchor() {}
6060

6161
SystemZInstrInfo::SystemZInstrInfo(SystemZSubtarget &sti)
62-
: SystemZGenInstrInfo(-1, -1),
62+
: SystemZGenInstrInfo(SystemZ::ADJCALLSTACKDOWN, SystemZ::ADJCALLSTACKUP),
6363
RI(sti.getSpecialRegisters()->getReturnFunctionAddressRegister()),
6464
STI(sti) {}
6565

@@ -1513,11 +1513,6 @@ bool SystemZInstrInfo::expandPostRAPseudo(MachineInstr &MI) const {
15131513
expandLoadStackGuard(&MI);
15141514
return true;
15151515

1516-
case SystemZ::ADJCALLSTACKDOWN:
1517-
case SystemZ::ADJCALLSTACKUP:
1518-
MI.eraseFromParent();
1519-
return true;
1520-
15211516
default:
15221517
return false;
15231518
}

0 commit comments

Comments
 (0)