[llvm] [CodeGen] Correctly handle non-standard cases in RemoveLoadsIntoFakeUses (PR #111551)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 8 14:52:35 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);
----------------
SLTozer wrote:
As long as it's fairly cheap to check whether two registers have any RegUnit overlap that should be fine, since we'll need to check each load seen against each FAKE_USE seen so far in the MBB.
https://github.com/llvm/llvm-project/pull/111551
More information about the llvm-commits
mailing list