This is an archive of the discontinued LLVM Phabricator instance.

[globalisel][tablegen] Fix incorrect inclusion of VS_32/VS_64 in [VS]GPRRegBank
Needs ReviewPublic

Authored by dsanders on May 19 2017, 4:49 AM.

Details

Summary

Re-worked the code that adds register classes to register banks to fix a bug
that occurs when subregister indices are re-used for distinct register classes.
This occurred on AMDGPU and caused VS_32/VS_64 to be incorrectly added to both
VGPRRegBank and SGPRRegBank.

Previously the code would inspect a register class (X) that is known to be in
the register bank and check whether it implied that another register bank (Y)
should also be a member. This code would consider Y to be covered if every
register was accessible by a subregister index that was used by X to access
subregisters. However, it did not check whether the subregisters of X were
present in Y.

This worked fine for AArch64, ARM, and X86 but on AMDGPU it was possible for
the subregisters of X to be missing from Y due to the re-use of subregister
indices.

Now the code checks that every register in Y is either in X or is a
subregister of a register in X.

This has also has a side-effect on X86. It now notices that GR64_TCW64
should be in GPRRegBank.

Event Timeline

dsanders created this revision.May 19 2017, 4:49 AM