[llvm] [NFC][SPIR-V] Assert to avoid null pointer dereference (PR #177952)

Viktoria Maximova via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 26 05:12:24 PST 2026


https://github.com/vmaksimo created https://github.com/llvm/llvm-project/pull/177952

The issue is found by static code analysis tool.

We expect scalar result type is determined in `getDotProductVectorType`. Per discussion:
https://github.com/llvm/llvm-project/pull/172050#pullrequestreview-3692008084

>From 86d6ceb460c74a69b6620f75440725bd5cbc2133 Mon Sep 17 00:00:00 2001
From: "Maksimova, Viktoria" <viktoria.maksimova at intel.com>
Date: Mon, 26 Jan 2026 05:07:45 -0800
Subject: [PATCH] [NFC][SPIR-V] Assert to avoid null pointer dereference

The issue is found by static code analysis tool.

We expect scalar result type is determined in `getDotProductVectorType`.
Per discussion:
https://github.com/llvm/llvm-project/pull/172050#pullrequestreview-3692008084
---
 llvm/lib/Target/SPIRV/SPIRVCombinerHelper.cpp | 1 +
 1 file changed, 1 insertion(+)

diff --git a/llvm/lib/Target/SPIRV/SPIRVCombinerHelper.cpp b/llvm/lib/Target/SPIRV/SPIRVCombinerHelper.cpp
index 693b74c1e06d7..881de7b4313ff 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCombinerHelper.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCombinerHelper.cpp
@@ -368,6 +368,7 @@ SPIRVCombinerHelper::getDotProductVectorType(Register ResReg, uint32_t K,
     assert(ScalarResType->isIntegerTy() || ScalarResType->isFloatingPointTy());
     break;
   }
+  assert(ScalarResType && "Could not determine scalar result type");
   Type *VecType =
       (K > 1 ? FixedVectorType::get(ScalarResType, K) : ScalarResType);
   return GR->getOrCreateSPIRVType(VecType, Builder,



More information about the llvm-commits mailing list