[llvm] [SPIR-V] Allow intrinsics with aggregate return type to reach GlobalISel (PR #108893)

Michal Paszkowski via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 19 08:11:37 PDT 2024


================
@@ -1101,6 +1130,71 @@ bool SPIRVInstructionSelector::selectFence(MachineInstr &I) const {
       .constrainAllUses(TII, TRI, RBI);
 }
 
+bool SPIRVInstructionSelector::selectOverflowArith(Register ResVReg,
+                                                   const SPIRVType *ResType,
+                                                   MachineInstr &I,
+                                                   unsigned Opcode) const {
+  Type *ResTy = nullptr;
+  StringRef ResName;
+  if (!GR.findValueAttrs(&I, ResTy, ResName))
+    report_fatal_error(
+        "Not enough info to select the arithmetic with overflow instruction");
+  if (!ResTy->isStructTy())
----------------
michalpaszkowski wrote:

Please add a nullptr check, currently this should not be an issue, but given that ValueAttrs is a global (in GR) further changes and use are expected:
```
if (!ResTy || !ResTy->isStructTy())
```
Additionally, I would opt for adding some checks in findValueAttrs, globals are difficult to debug.

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


More information about the llvm-commits mailing list