RegAllocGreedy: Avoid overflowing priority bitfields
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Sat, 23 Jul 2022 14:13:25 +0000 (10:13 -0400)
committerMatt Arsenault <Matthew.Arsenault@amd.com>
Thu, 15 Sep 2022 14:38:40 +0000 (10:38 -0400)
commit63d1d37d35e513632e9d4fcc1910ed4e9e3525d0
treec8519c07066576ad485d38d5612087e5c82f588f
parent7435ae25abfbe4de371f1776fc4be8a8768c0e8a
RegAllocGreedy: Avoid overflowing priority bitfields

The class priority is expected to be at most 5 bits before it starts
clobbering bits used for other fields. Also clamp the instruction
distance in case we have millions of instructions.

AMDGPU was accidentally overflowing into the global priority bit in
some cases. I think in principal we would have wanted this, but in the
cases I've looked at, it had the counter intuitive effect and
de-prioritized the large register tuple.

Avoid using weird bit hack PPC uses for global priority. The
AllocationPriority field is really 5 bits, and PPC was relying on
overflowing this to 6-bits to forcibly set the global priority
bit. Split this out as a separate flag to avoid having magic behavior
for values above 31.
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/include/llvm/Target/Target.td
llvm/lib/CodeGen/RegAllocGreedy.cpp
llvm/lib/Target/PowerPC/PPCRegisterInfoMMA.td
llvm/utils/TableGen/CodeGenRegisters.cpp
llvm/utils/TableGen/CodeGenRegisters.h
llvm/utils/TableGen/RegisterInfoEmitter.cpp