[llvm] [DebugInfo][RegisterCoalescer] Drop DBG_VALUEs with unsupported register class (PR #143132)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 6 09:09:55 PDT 2025
================
@@ -118,28 +118,44 @@ MachineRegisterInfo::constrainRegAttrs(Register Reg,
return true;
}
-bool
+std::pair<bool, SmallVector<MachineInstr *, 8>>
MachineRegisterInfo::recomputeRegClass(Register Reg) {
const TargetInstrInfo *TII = MF->getSubtarget().getInstrInfo();
const TargetRegisterClass *OldRC = getRegClass(Reg);
const TargetRegisterInfo *TRI = getTargetRegisterInfo();
+ // Largest legal super-class for non-debug uses.
const TargetRegisterClass *NewRC = TRI->getLargestLegalSuperClass(OldRC, *MF);
+ // Largest legal super-class for all uses.
+ const TargetRegisterClass *NewRCWithDebug = NewRC;
+ SmallVector<MachineInstr *, 8> DebugInsns;
// Stop early if there is no room to grow.
if (NewRC == OldRC)
- return false;
+ return {false, {}};
// Accumulate constraints from all uses.
- for (MachineOperand &MO : reg_nodbg_operands(Reg)) {
- // Apply the effect of the given operand to NewRC.
+ for (MachineOperand &MO : reg_operands(Reg)) {
MachineInstr *MI = MO.getParent();
unsigned OpNo = &MO - &MI->getOperand(0);
- NewRC = MI->getRegClassConstraintEffect(OpNo, NewRC, TII, TRI);
+ if (MO.isDebug()) {
+ DebugInsns.push_back(MI);
----------------
arsenm wrote:
This is much too aggressive, not every debug instruction needs to be dropped
https://github.com/llvm/llvm-project/pull/143132
More information about the llvm-commits
mailing list