================
@@ -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:
It will only be switched if the use is defined at this line. If the use is omitted or marked as `implicit-def`, the test passes.
Multiple implicit operands will be added if they are subregs of `Reg` within `LiveVariables::HandlePhysRegUse`, so I believe it is already being modeled.
https://github.com/llvm/llvm-project/pull/119446