[PATCH] D146734: [CodeGen] Use RegUnits in RegisterClassInfo::getLastCalleeSavedAlias

Quentin Colombet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 4 06:50:40 PDT 2023


qcolombet added inline comments.


================
Comment at: llvm/include/llvm/CodeGen/RegisterClassInfo.h:121
+    for (MCRegUnitIterator UI(PhysReg, TRI); UI.isValid(); ++UI) {
+      CSR = CalleeSavedAliases[*UI];
+      if (CSR)
----------------
foad wrote:
> qcolombet wrote:
> > Cannot this get out of range?
> > I.e., I believe we could assert that `*UI` is bigger than `CalleeSavedAliases.size()`.
> > 
> > I am wondering why the check was there in the previous implementation.
> I don't know! I just found that when I removed the check, everything still worked.
Oh boy!
Looking at the history of the change, I don't see any explanation why we needed that check. (Unless I am mistaken, the check has been introduced with https://reviews.llvm.org/D28566.)

Could it be possible to call `getLastCalleeSavedAlias` before `CalleeSavedAliases` has been initialized?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146734



More information about the llvm-commits mailing list