[PATCH] D151289: [AMDGPU] Check if register is non-null before calling isSubRegisterEq (NFCI)

Sergei Barannikov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 24 00:11:57 PDT 2023


barannikov88 marked an inline comment as done.
barannikov88 added a comment.

In D151289#4367115 <https://reviews.llvm.org/D151289#4367115>, @foad wrote:

>> D151036 <https://reviews.llvm.org/D151036> adds an assertions that prohibits iterating over sub- and
>> super-registers of a null register. This is already the case when
>> iterating over register units of a null register, and worked by
>> accident for sub- and super-registers.
>
> OK. I had been wondering if it made sense to treat 0 as a kind of empty register, i.e. no regunits, no subregs, no aliases, (not sure about superregs). But if the existing code did not allow you to iterate its regunits then I think it's pretty clear that this was not the intended design.

I found only a few cases where this caused problems so far (see the stack). There may be more hidden, but overall I think this change is in the right direction.
I wish there was a way to enumerate all registers without a for-loop like `for (i = 0, e = TRI->getNumRegs(); i != e; ++i)`, this would halven the number of issues.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151289/new/

https://reviews.llvm.org/D151289



More information about the llvm-commits mailing list