[llvm] [SPIRV] Add a `SPIRVTypeInst` type with some guardrails (PR #179947)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 5 09:04:20 PST 2026
================
@@ -140,6 +143,9 @@ SPIRVTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
inline Register getTypeReg(MachineRegisterInfo *MRI, Register OpReg) {
SPIRVType *TypeInst = MRI->getVRegDef(OpReg);
+ assert(!SPIRVTypeInst::definesATypeRegister(TypeInst) &&
+ "The TypeInst is never a type, because this function doesn't make any "
+ "sense");
----------------
jmmartinez wrote:
I agree with you on that. The assert should not make it into trunk. The idea was to highlight the situation that I triggered me to propose this.
> Shouldn't the function be removed instead?
Ideally yes. To verify if we could remove it, I've tried replacing it by:
```cpp
Register getTypeReg(MachineRegisterInfo *MRI, Register OpReg) { return OpReg; }
```
The lit test pass.
https://github.com/llvm/llvm-project/pull/179947
More information about the llvm-commits
mailing list