[llvm] Revert "llvm/lib/CodeGen/TargetSchedule.cpp:132:12: warning: Assert statement modifies 'NIter'" (PR #91079)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Sat May 4 11:42:53 PDT 2024


https://github.com/dwblaikie created https://github.com/llvm/llvm-project/pull/91079

Reverts llvm/llvm-project#90982

NIter was only declared in !NDEBUG, and only used for assertions - so it was correct that it was incremented inside the assertion. (& in fact now the non-asserts build fails, because the variable is incremented even though it isn't declared)

>From be1ad4df38e6136cb1bef7d8b9b53a43451771eb Mon Sep 17 00:00:00 2001
From: David Blaikie <dblaikie at gmail.com>
Date: Sat, 4 May 2024 11:41:26 -0700
Subject: [PATCH] =?UTF-8?q?Revert=20"llvm/lib/CodeGen/TargetSchedule.cpp:1?=
 =?UTF-8?q?32:12:=20warning:=20Assert=20statement=E2=80=A6"?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

This reverts commit 18d1df4633c3964e12ec46f3fa92e60ab21842fd.
---
 llvm/lib/CodeGen/TargetSchedule.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/TargetSchedule.cpp b/llvm/lib/CodeGen/TargetSchedule.cpp
index b5db2a671f7d04..ce59b096992d8e 100644
--- a/llvm/lib/CodeGen/TargetSchedule.cpp
+++ b/llvm/lib/CodeGen/TargetSchedule.cpp
@@ -129,8 +129,7 @@ resolveSchedClass(const MachineInstr *MI) const {
   unsigned NIter = 0;
 #endif
   while (SCDesc->isVariant()) {
-    ++NIter;
-    assert(NIter < 6 && "Variants are nested deeper than the magic number");
+    assert(++NIter < 6 && "Variants are nested deeper than the magic number");
 
     SchedClass = STI->resolveSchedClass(SchedClass, MI, this);
     SCDesc = SchedModel.getSchedClassDesc(SchedClass);



More information about the llvm-commits mailing list