[llvm] [DebugInfo][RegisterCoalescer] Drop DBG_VALUEs with unsupported register class (PR #143132)

Vladislav Dzhidzhoev via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 6 08:35:39 PDT 2025


dzhidzhoev wrote:

> > After the register inflation, some registers may be changed to a type that is not supported by DBG_VALUE. It may happen because MachineRegisterInfo::recomputeRegClass() doesn't take DBG_VALUEs into account.
> 
> I don't understand this; DBG_VALUE should have no register constraints. It should not be possible for it to not support a class, and recomputeRegClass would never need to consider constraints from it

Thank you for clarification. Sorry if I chose the wrong wording, or misinterpreted something, don't have much experience with this part of the backend. 



> > Register class GR32 does not fully support subreg index sub_8bit
> 
> Is the problem the coalescer introduced a new subregister use? If we need to, we could maybe relax the verifier's rules for subregister indexes on these

We can consider `compiler-rt/lib/builtins/adddf3.c`, where I encountered the problem. After ISel, there are DBG_VALUEs for the variable "sticky" referring to "%X:gr8" register. During register coalescing, "%X:gr8" gets merged into "%Y.sub_8bit:gr32_abcd". Then, all non-dbg uses of "%Y.sub_8bit:gr32_abcd" get removed/merged into something else. After coalescing steps, RegisterCoalescer inflates gr32_abcd into gr32, and DBG_VALUE gets invalid "%Y.sub_8bit:gr32" operand (and it causes verification failure in `MachineVerifier::visitMachineOperand()`.

https://github.com/llvm/llvm-project/pull/143132


More information about the llvm-commits mailing list