[llvm] [RegAllocBase] Produce IMPLICIT_DEF instead of COPY undef during cleanupFailedVReg (PR #147392)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Thu Jul 10 02:59:18 PDT 2025
arsenm wrote:
Option 2:
```
diff --git a/llvm/lib/CodeGen/TargetInstrInfo.cpp b/llvm/lib/CodeGen/TargetInstrInfo.cpp
index 8b82deb2a9d8..8c23dff565ab 100644
--- a/llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ b/llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -773,10 +773,14 @@ MachineInstr *TargetInstrInfo::foldMemoryOperand(MachineInstr &MI,
const MachineOperand &MO = MI.getOperand(1 - Ops[0]);
MachineBasicBlock::iterator Pos = MI;
- if (Flags == MachineMemOperand::MOStore)
- storeRegToStackSlot(*MBB, Pos, MO.getReg(), MO.isKill(), FI, RC, TRI,
- Register());
- else
+ if (Flags == MachineMemOperand::MOStore) {
+ if (MO.isUndef()) {
+ BuildMI(*MBB, Pos, MI.getDebugLoc(), get(TargetOpcode::KILL)).add(MO);
+ } else {
+ storeRegToStackSlot(*MBB, Pos, MO.getReg(), MO.isKill(), FI, RC, TRI,
+ Register());
+ }
+ } else
loadRegFromStackSlot(*MBB, Pos, MO.getReg(), FI, RC, TRI, Register());
return &*--Pos;
}
```
https://github.com/llvm/llvm-project/pull/147392
More information about the llvm-commits
mailing list