[llvm] [SPIR-V] Return false after non-constant offset error in generateSampleImage (PR #203512)
Arseniy Obolenskiy via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 04:46:36 PDT 2026
https://github.com/aobolensk created https://github.com/llvm/llvm-project/pull/203512
generateSampleImage emitted the diagnostic but kept building the instruction, producing a malformed OpImageSample with the offset silently dropped
>From b837586343c95da886c2e823a745e436936356d9 Mon Sep 17 00:00:00 2001
From: Arseniy Obolenskiy <arseniy.obolenskiy at amd.com>
Date: Fri, 12 Jun 2026 13:44:19 +0200
Subject: [PATCH] [SPIR-V] Return false after non-constant offset error in
generateSampleImage
generateSampleImage emitted the diagnostic but kept building the instruction, producing a malformed OpImageSample with the offset silently dropped
---
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp | 1 +
llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index 8fbde6f08c7c3..c9c44f86a6815 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -5671,6 +5671,7 @@ bool SPIRVInstructionSelector::generateSampleImage(
else {
Pos.emitGenericError(
"Non-constant offsets are not supported in sample instructions.");
+ return false;
}
}
if (ImOps.MinLod)
diff --git a/llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll b/llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll
index 672715b37fbcf..bead56c600a7e 100644
--- a/llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll
+++ b/llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll
@@ -1,4 +1,4 @@
-; RUN: not llc -O0 -mtriple=spirv-vulkan-compute %s -o /dev/null 2>&1 | FileCheck %s
+; RUN: not llc -O0 -mtriple=spirv-vulkan-compute %s -o - 2>&1 | FileCheck %s
; CHECK: error: {{.*}} Non-constant offsets are not supported in sample instructions.
More information about the llvm-commits
mailing list