https://github.com/brunodf-snps created 
https://github.com/llvm/llvm-project/pull/175860

These tests were not testing the loop metadata that they suggest to be testing. 
They would define FileCheck variables such as `UNROLL_8` for metadata nodes and 
then later redefine instead of use them (redefinition always succeeds and thus 
checks nothing). The error was likely introduced because the earlier loop 
metadata nodes, which must define the variables at the first occurrence, were 
copy-pasted for later loop metadata nodes, without realizing that the variable 
definitions in the FileCheck pattern must be changed to uses to match later 
occurrences of the same metadata node. By matching the metadata section with a 
block of DAG patterns, we can define variables such as `UNROLL_8` with a 
pattern that matches at the metadata node definition, even if it occurs later, 
and the loop metadata nodes can be matched with uniform patterns. This system 
is also used in the `pragma-loop.cpp` test.

>From e597cc672f4467ac016def1e996267b9432311c9 Mon Sep 17 00:00:00 2001
From: Bruno De Fraine <[email protected]>
Date: Wed, 7 Jan 2026 12:14:11 +0100
Subject: [PATCH] [clang][CodeGenCXX] Fix pragma unroll test patterns (NFC)

These tests were not testing the loop metadata that they suggest to be
testing. They would define FileCheck variables such as UNROLL_8 for
metadata nodes and then later redefine instead of use them (redefinition
always succeeds and thus checks nothing). The error was likely
introduced because the earlier loop metadata nodes, which must define
the variables at the first occurrence, were copy-pasted for later loop
metadata nodes, without realizing that the variable definitions in the
FileCheck pattern must be changed to uses to match later occurrences of
the same metadata node. By matching the metadata section with a block of
DAG patterns, we can define variables such as UNROLL_8 at the metadata
node itself, even if it occurs later, and the loop metadata nodes can be
matched with uniform patterns. This system is also used in the
pragma-loop.cpp test.
---
 clang/test/CodeGenCXX/pragma-gcc-unroll.cpp | 33 +++++++++++----------
 clang/test/CodeGenCXX/pragma-unroll.cpp     | 33 +++++++++++----------
 2 files changed, 36 insertions(+), 30 deletions(-)

diff --git a/clang/test/CodeGenCXX/pragma-gcc-unroll.cpp 
b/clang/test/CodeGenCXX/pragma-gcc-unroll.cpp
index 85f10fcdff14d..0c7fc527eca65 100644
--- a/clang/test/CodeGenCXX/pragma-gcc-unroll.cpp
+++ b/clang/test/CodeGenCXX/pragma-gcc-unroll.cpp
@@ -144,18 +144,21 @@ void test_value_dependent(int n) {
   value_dependent<true>(n);
 }
 
-// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], [[MP:![0-9]+]], 
![[UNROLL_ENABLE:.*]]}
-// CHECK: ![[UNROLL_ENABLE]] = !{!"llvm.loop.unroll.enable"}
-// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2:.*]], ![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
-// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], [[MP]], ![[UNROLL_8:.*]]}
-// CHECK: ![[UNROLL_8]] = !{!"llvm.loop.unroll.count", i32 8}
-// CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[UNROLL_4:.*]]}
-// CHECK: ![[UNROLL_4]] = !{!"llvm.loop.unroll.count", i32 4}
-// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_17]] = distinct !{![[LOOP_17]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
+// CHECK-DAG: ![[MP:[0-9]+]] = !{!"llvm.loop.mustprogress"}
+//
+// CHECK-DAG: ![[UNROLL_ENABLE:[0-9]+]] = !{!"llvm.loop.unroll.enable"}
+// CHECK-DAG: ![[UNROLL_DISABLE:[0-9]+]] = !{!"llvm.loop.unroll.disable"}
+// CHECK-DAG: ![[UNROLL_4:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 4}
+// CHECK-DAG: ![[UNROLL_8:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 8}
+//
+// CHECK-DAG: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[MP]], 
![[UNROLL_ENABLE]]}
+// CHECK-DAG: ![[LOOP_2]] = distinct !{![[LOOP_2]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[UNROLL_4]]}
+// CHECK-DAG: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_17]] = distinct !{![[LOOP_17]], ![[MP]], 
![[UNROLL_DISABLE]]}
diff --git a/clang/test/CodeGenCXX/pragma-unroll.cpp 
b/clang/test/CodeGenCXX/pragma-unroll.cpp
index 6754788b72436..75f0c54ed9131 100644
--- a/clang/test/CodeGenCXX/pragma-unroll.cpp
+++ b/clang/test/CodeGenCXX/pragma-unroll.cpp
@@ -144,18 +144,21 @@ void test_value_dependent(int n) {
   value_dependent<true>(n);
 }
 
-// CHECK: ![[LOOP_1]] = distinct !{![[LOOP_1]], [[MP:![0-9]+]], 
![[UNROLL_ENABLE:.*]]}
-// CHECK: ![[UNROLL_ENABLE]] = !{!"llvm.loop.unroll.enable"}
-// CHECK: ![[LOOP_2]] = distinct !{![[LOOP_2:.*]], ![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[UNROLL_DISABLE]] = !{!"llvm.loop.unroll.disable"}
-// CHECK: ![[LOOP_3]] = distinct !{![[LOOP_3]], [[MP]], ![[UNROLL_8:.*]]}
-// CHECK: ![[UNROLL_8]] = !{!"llvm.loop.unroll.count", i32 8}
-// CHECK: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[UNROLL_4:.*]]}
-// CHECK: ![[UNROLL_4]] = !{!"llvm.loop.unroll.count", i32 4}
-// CHECK: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[UNROLL_8:.*]]}
-// CHECK: ![[LOOP_14]] = distinct !{![[LOOP_14]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_15]] = distinct !{![[LOOP_15]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_16]] = distinct !{![[LOOP_16]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
-// CHECK: ![[LOOP_17]] = distinct !{![[LOOP_17]], [[MP]], 
![[UNROLL_DISABLE:.*]]}
+// CHECK-DAG: ![[MP:[0-9]+]] = !{!"llvm.loop.mustprogress"}
+//
+// CHECK-DAG: ![[UNROLL_ENABLE:[0-9]+]] = !{!"llvm.loop.unroll.enable"}
+// CHECK-DAG: ![[UNROLL_DISABLE:[0-9]+]] = !{!"llvm.loop.unroll.disable"}
+// CHECK-DAG: ![[UNROLL_4:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 4}
+// CHECK-DAG: ![[UNROLL_8:[0-9]+]] = !{!"llvm.loop.unroll.count", i32 8}
+//
+// CHECK-DAG: ![[LOOP_1]] = distinct !{![[LOOP_1]], ![[MP]], 
![[UNROLL_ENABLE]]}
+// CHECK-DAG: ![[LOOP_2]] = distinct !{![[LOOP_2]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_3]] = distinct !{![[LOOP_3]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[UNROLL_4]]}
+// CHECK-DAG: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_7]] = distinct !{![[LOOP_7]], ![[MP]], ![[UNROLL_8]]}
+// CHECK-DAG: ![[LOOP_14]] = distinct !{![[LOOP_14]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_15]] = distinct !{![[LOOP_15]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_16]] = distinct !{![[LOOP_16]], ![[MP]], 
![[UNROLL_DISABLE]]}
+// CHECK-DAG: ![[LOOP_17]] = distinct !{![[LOOP_17]], ![[MP]], 
![[UNROLL_DISABLE]]}

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to