[llvm] [LLVM] Add 'maybe_unused' to variable only used in asserts. (PR #177632)

via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 23 10:13:54 PST 2026


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-transforms

Author: None (cmtice)

<details>
<summary>Changes</summary>

Builds with -Werror that don't use asserts can fail without this annotation.

---
Full diff: https://github.com/llvm/llvm-project/pull/177632.diff


1 Files Affected:

- (modified) llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp (+1-1) 


``````````diff
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
index 247b4d40eee4d..582ec1dbcec98 100644
--- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -1225,7 +1225,7 @@ struct DSEState {
     auto IBounded = InvisibleToCallerAfterRetBounded.find(V);
     if (IBounded != InvisibleToCallerAfterRetBounded.end()) {
       int64_t ValueOffset;
-      const Value *BaseValue =
+      [[maybe_unused]] const Value *BaseValue =
           GetPointerBaseWithConstantOffset(Ptr, ValueOffset, DL);
       assert(BaseValue == V);
       // This store is only invisible after return if we are in bounds of the

``````````

</details>


https://github.com/llvm/llvm-project/pull/177632


More information about the llvm-commits mailing list