[PATCH] D105953: [MachineVerifier] Diagnose invalid INSERT_SUBREGs

Mikael Holmén via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 20 23:44:51 PDT 2021


uabelho added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineVerifier.cpp:1787
+    unsigned InsertedSize =
+        TRI->getRegSizeInBits(MI->getOperand(2).getReg(), *MRI);
+    unsigned SubRegSize = TRI->getSubRegIdxSize(MI->getOperand(3).getImm());
----------------
uabelho wrote:
> Don't you need to take operand 2's subreg into account here?
> 
> I'm seeing failures for cases where
> ```
>  MI->getOperand(2).getReg()
> ```
> is indeed too big, but
> ```
> MI->getOperand(2).getSubReg()
> ```
> is specifying a subreg of a small enough size so there is no problem.
This seems to work better for me:
```
    unsigned InsertedSize;
    if (unsigned SubIdx = MI->getOperand(2).getSubReg())
      InsertedSize = TRI->getSubRegIdxSize(SubIdx);
    else
      InsertedSize =
        TRI->getRegSizeInBits(MI->getOperand(2).getReg(), *MRI);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105953



More information about the llvm-commits mailing list