DeadMachineInstructionElim: Don't repeat per-function init

This was happening for every iteration but only needs to be done once.
This commit is contained in:
Matt Arsenault 2022-09-12 20:58:00 -04:00
parent 243632c63e
commit b7dae832e6
1 changed files with 7 additions and 4 deletions

View File

@ -107,6 +107,13 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {
bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
if (skipFunction(MF.getFunction()))
return false;
MRI = &MF.getRegInfo();
const TargetSubtargetInfo &ST = MF.getSubtarget();
TII = ST.getInstrInfo();
LivePhysRegs.init(*ST.getRegisterInfo());
bool AnyChanges = eliminateDeadMI(MF);
while (AnyChanges && eliminateDeadMI(MF))
;
@ -115,10 +122,6 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
bool DeadMachineInstructionElim::eliminateDeadMI(MachineFunction &MF) {
bool AnyChanges = false;
MRI = &MF.getRegInfo();
TII = MF.getSubtarget().getInstrInfo();
LivePhysRegs.init(*MF.getSubtarget().getRegisterInfo());
// Loop over all instructions in all blocks, from bottom to top, so that it's
// more likely that chains of dependent but ultimately dead instructions will