[llvm] [CodeGen] Correctly handle non-standard cases in RemoveLoadsIntoFakeUses (PR #111551)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 12 20:07:18 PST 2024
================
@@ -86,20 +93,22 @@ bool RemoveLoadsIntoFakeUses::runOnMachineFunction(MachineFunction &MF) {
const TargetInstrInfo *TII = ST.getInstrInfo();
const TargetRegisterInfo *TRI = ST.getRegisterInfo();
- SmallDenseMap<Register, SmallVector<MachineInstr *>> RegFakeUses;
+ SmallVector<MachineInstr *> RegFakeUses;
LivePhysRegs.init(*TRI);
SmallVector<MachineInstr *, 16> Statepoints;
for (MachineBasicBlock *MBB : post_order(&MF)) {
+ RegFakeUses.clear();
LivePhysRegs.addLiveOuts(*MBB);
for (MachineInstr &MI : make_early_inc_range(reverse(*MBB))) {
if (MI.isFakeUse()) {
- for (const MachineOperand &MO : MI.operands()) {
- // Track the Fake Uses that use this register so that we can delete
- // them if we delete the corresponding load.
- if (MO.isReg())
- RegFakeUses[MO.getReg()].push_back(&MI);
- }
+ if (MI.getNumOperands() == 0 || !MI.getOperand(0).isReg())
+ continue;
+ const MachineOperand &FakeUseOp = MI.getOperand(0);
+ // Track the Fake Uses that use these register units so that we can
+ // delete them if we delete the corresponding load.
+ if (FakeUseOp.isReg())
----------------
arsenm wrote:
This is checking isReg twice. But you can just remove the operand checks, take all the instructions, and use readRegister and completely avoid the artificial restriction that this only have one operand
https://github.com/llvm/llvm-project/pull/111551
More information about the llvm-commits
mailing list