[llvm] [LiveVariables] Mark use as implicit-def if defined at instr (PR #119446)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 16 18:12:10 PST 2024
================
@@ -277,11 +277,13 @@ void LiveVariables::HandlePhysRegUse(Register Reg, MachineInstr &MI) {
continue;
if (PartDefRegs.count(SubReg))
continue;
+
+ // Check if SubReg is defined at LastPartialDef.
+ bool IsDefinedHere = LastPartialDef->modifiesRegister(SubReg, TRI);
// This part of Reg was defined before the last partial def. It's killed
// here.
- LastPartialDef->addOperand(MachineOperand::CreateReg(SubReg,
- false/*IsDef*/,
- true/*IsImp*/));
+ LastPartialDef->addOperand(
+ MachineOperand::CreateReg(SubReg, IsDefinedHere, true /*IsImp*/));
----------------
jofrn wrote:
Yes, it can be skipped. However, `llvm/test/CodeGen/AArch64/ldrpre-ldr-merge.mir` would need to be updated to not mark `implicit-def $w2_hi`, which may be incorrect, so I believe it is better to leave the `implicit-def` in.
I'd argue that we are not really replacing what used to be a use with a def. They should have been defs all along because the sub or super register has a definition at this line.
If we do not fix it here, the logic to fix it in LiveRangeCalc.cpp needs to update `LiveRangeCalc::findReachingDefs` to take into consideration definitions that are found at the current instruction. And it propagates a change to be made in RegisterPressure.cpp, so I think it is cleaner to have it here.
https://github.com/llvm/llvm-project/pull/119446
More information about the llvm-commits
mailing list