[llvm] [GlobalISel] Remove dead VRegs after instruction selection (PR #73892)

Evgenii Kudriashov via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 11 20:22:39 PST 2023


e-kud wrote:

> I thought the problematic context was when registers are only referenced by debug instructions? Can we do something about those specifically instead?

The problematic context is instructions that were created and deleted during whole `GlobalISel` pipeline. Such instructions create virtual registers for themselves. Also such instructions are not selected (obviously they were replaced or deleted) and virtual registers used by these instructions don't have a `RegClass` because it is assigned during selecting MIR instruction.

Probably, the context, when registers are only referenced by debug instructions, is also actual. But I'm mostly concentrated on the context I've described above.

> If you have a register with an unset class, it was mis-selected. We shouldn't need to inspect the full set of registers, all used registers should be naturally encountered during the select process

We may have a register with an unset class and this register is not used anywhere. That's why the problem is hidden until we traverse all virtual registers and ask their `RegClass`. These registers are the problem. Should they have a `RegClass` or it is a problem of one who traverses such registers. In other words, can a dead register have an unset class immediately after instruction selection.






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


More information about the llvm-commits mailing list