[llvm] Redundant Assert In AsmWriter (PR #129288)

JP Hafer via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 28 11:21:26 PST 2025


https://github.com/jph-13 created https://github.com/llvm/llvm-project/pull/129288

The assert in GetConstant checks if Bound is constant. However, GetConstant is only called when IsConstant==true.

>From 1e08ffe43a2a3896650fc0094f35a77679e2bee1 Mon Sep 17 00:00:00 2001
From: Jason Hafer <jhafer at mathworks.com>
Date: Fri, 28 Feb 2025 14:19:54 -0500
Subject: [PATCH] Redundant Assert In AsmWriter

---
 llvm/lib/IR/AsmWriter.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index a52c4d88ac836..306186d200e26 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2117,7 +2117,6 @@ static void writeDIGenericSubrange(raw_ostream &Out, const DIGenericSubrange *N,
   };
 
   auto GetConstant = [&](Metadata *Bound) -> int64_t {
-    assert(IsConstant(Bound) && "Expected constant");
     auto *BE = dyn_cast_or_null<DIExpression>(Bound);
     return static_cast<int64_t>(BE->getElement(1));
   };



More information about the llvm-commits mailing list