[llvm] [SPIRV] Fix -Wunused-variable (PR #219207)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 06:09:31 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-backend-spir-v
Author: Aiden Grossman (boomanaiden154)
<details>
<summary>Changes</summary>
These variables are only used in assertions but are used multiple times/do not make sense to inline, so mark them [[maybe_unused]].
---
Full diff: https://github.com/llvm/llvm-project/pull/219207.diff
2 Files Affected:
- (modified) llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp (+1-1)
- (modified) llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp (+1-1)
``````````diff
diff --git a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
index 433edbfb12a9f..29d21fb9447ca 100644
--- a/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp
@@ -635,7 +635,7 @@ Register SPIRVGlobalRegistry::getOrCreateConstVector(const APInt &Val,
"Expected vector type for constant vector creation");
const FixedVectorType *LLVMVecTy = cast<FixedVectorType>(LLVMTy);
Type *LLVMBaseTy = LLVMVecTy->getElementType();
- const auto &ST = I.getMF()->getSubtarget<SPIRVSubtarget>();
+ [[maybe_unused]] const auto &ST = I.getMF()->getSubtarget<SPIRVSubtarget>();
assert((LLVMBaseTy->isIntegerTy() ||
(LLVMBaseTy->isPointerTy() &&
ST.canUseExtension(
diff --git a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
index e64c5ad38ba2a..2ec4ede8dd8f5 100644
--- a/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp
@@ -6745,7 +6745,7 @@ bool SPIRVInstructionSelector::extractSubvector(
[[maybe_unused]] uint64_t InputSize =
GR.getScalarOrVectorComponentCount(InputType);
uint64_t ResultSize = GR.getScalarOrVectorComponentCount(ResType);
- bool IsLongVectorEXT =
+ [[maybe_unused]] bool IsLongVectorEXT =
STI.canUseExtension(SPIRV::Extension::SPV_EXT_long_vector);
assert((InputSize > 1 || IsLongVectorEXT) && "The input must be a vector.");
assert((ResultSize > 1 || IsLongVectorEXT) && "The result must be a vector.");
``````````
</details>
https://github.com/llvm/llvm-project/pull/219207
More information about the llvm-commits
mailing list