[llvm] [SPIRV] Fix -Wunused-variable (PR #219207)
Aiden Grossman via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 27 06:08:52 PDT 2026
https://github.com/boomanaiden154 created https://github.com/llvm/llvm-project/pull/219207
These variables are only used in assertions but are used multiple times/do not make sense to inline, so mark them [[maybe_unused]].
>From 408e80092e3fd56053085eaeaddcabe4ffa68cc5 Mon Sep 17 00:00:00 2001
From: Aiden Grossman <aidengrossman at google.com>
Date: Thu, 27 Aug 2026 13:07:56 +0000
Subject: [PATCH] [SPIRV] Fix -Wunused-variable
These variables are only used in assertions but are used multiple
times/do not make sense to inline, so mark them [[maybe_unused]].
---
llvm/lib/Target/SPIRV/SPIRVGlobalRegistry.cpp | 2 +-
llvm/lib/Target/SPIRV/SPIRVInstructionSelector.cpp | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
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.");
More information about the llvm-commits
mailing list