[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 07:03:50 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:

What I was trying to highlight is that the old `SPIRVType` doesn't have a clear meaning and seems misused.

Here the assertion enforces that the register defined by `SPIRVType` is not a type. I'd expect this assertion to fail. I'd expect a `SPIRVType` to define a type... at least sometimes. But it's not the case (at least in our test-suite).

https://github.com/llvm/llvm-project/pull/179947


More information about the llvm-commits mailing list