[llvm] [SPIR-V] Return false after non-constant offset error in generateSampleImage (PR #203512)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 12 04:47:32 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Arseniy Obolenskiy (aobolensk)
<details>
<summary>Changes</summary>
generateSampleImage emitted the diagnostic but kept building the instruction, producing a malformed OpImageSample with the offset silently dropped
---
Full diff: https://github.com/llvm/llvm-project/pull/203512.diff
2 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+1)
- (modified) llvm/test/CodeGen/SPIRV/hlsl-resources/SampleErrors.ll (+1-1)
``````````diff
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.
``````````
</details>
https://github.com/llvm/llvm-project/pull/203512
More information about the llvm-commits
mailing list