[Mlir-commits] [mlir] [MLIR] Add [[maybe_unused]] to variables on used in assert (PR #123037)

Will Froom llvmlistbot at llvm.org
Wed Jan 15 02:14:12 PST 2025


https://github.com/WillFroom created https://github.com/llvm/llvm-project/pull/123037

Add [[maybe_unused]] to suppresses warnings when  `-NDEBUG` is enabled


>From 6b7d4f9c1047c85d82ff35cc8f237118b2897b01 Mon Sep 17 00:00:00 2001
From: Will Froom <willfroom at google.com>
Date: Wed, 15 Jan 2025 10:08:02 +0000
Subject: [PATCH] [MLIR] Add [[maybe_unused]] to variables on used in assert

---
 .../lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
index a674a590091815..95064083b21d44 100644
--- a/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
+++ b/mlir/lib/Dialect/Vector/Transforms/VectorEmulateNarrowType.cpp
@@ -1291,7 +1291,7 @@ using ExtractNBitsFn =
 /// bitwise ops to avoid leaving LLVM to scramble with peephole optimizations.
 static Value rewriteI4ToI8Ext(PatternRewriter &rewriter, Location loc,
                               Value srcValue, const ExtractNBitsFn &extFn) {
-  auto srcVecType = cast<VectorType>(srcValue.getType());
+  [[maybe_unused]] auto srcVecType = cast<VectorType>(srcValue.getType());
   assert(srcVecType.getElementType().isSignlessInteger(4) &&
          "Expected i4 type");
 
@@ -1311,7 +1311,7 @@ static Value rewriteI4ToI8Ext(PatternRewriter &rewriter, Location loc,
 /// bitwise ops to avoid leaving LLVM to scramble with peephole optimizations.
 static Value rewriteI2ToI8Ext(PatternRewriter &rewriter, Location loc,
                               Value srcValue, const ExtractNBitsFn &extFn) {
-  VectorType srcVecType = cast<VectorType>(srcValue.getType());
+  [[maybe_unused]] VectorType srcVecType = cast<VectorType>(srcValue.getType());
   assert(srcVecType.getElementType().isSignlessInteger(2) &&
          "Expected i2 type");
 



More information about the Mlir-commits mailing list