[llvm] [CodeGen] Correctly handle non-standard cases in RemoveLoadsIntoFakeUses (PR #111551)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 9 00:16:24 PDT 2024
================
@@ -86,20 +86,23 @@ bool RemoveLoadsIntoFakeUses::runOnMachineFunction(MachineFunction &MF) {
const TargetInstrInfo *TII = ST.getInstrInfo();
const TargetRegisterInfo *TRI = ST.getRegisterInfo();
- SmallDenseMap<Register, SmallVector<MachineInstr *>> RegFakeUses;
+ SmallDenseMap<MCRegUnit, 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())
+ for (MCRegUnit Unit : TRI->regunits(FakeUseOp.getReg()))
+ RegFakeUses[Unit].push_back(&MI);
----------------
arsenm wrote:
It's cheaper than maintaining many map entries, that's kind of the point
https://github.com/llvm/llvm-project/pull/111551
More information about the llvm-commits
mailing list