[PATCH] D135473: [llvm-reduce] Fix di-metadata pass test failures

Matthew Voss via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 11:26:30 PDT 2022


ormris created this revision.
ormris added reviewers: arsenm, MatzeB, aeubanks.
Herald added a project: All.
ormris requested review of this revision.
Herald added subscribers: llvm-commits, wdng.
Herald added a project: LLVM.

We're seeing intermittent failures in upstream bots. See:

https://lab.llvm.org/buildbot/#/builders/139/builds/29185
https://lab.llvm.org/buildbot/#/builders/238/builds/295

This appears to be due to the unstable iteration order of DenseSet. Since we're trying to reduce a tree, it makes sense to attempt reductions from the top down.

This also addresses post-review comments from @MatzeB.


https://reviews.llvm.org/D135473

Files:
  llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py
  llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
  llvm/test/tools/llvm-reduce/remove-dimetadata.ll
  llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp


Index: llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
@@ -27,13 +27,13 @@
 using MDNodeList = SmallVector<MDNode *>;
 
 void identifyUninterestingMDNodes(Oracle &O, MDNodeList &MDs) {
-  DenseSet<std::tuple<MDNode *, size_t, MDNode *>> Tuples;
+  SetVector<std::tuple<MDNode *, size_t, MDNode *>> Tuples;
   std::vector<MDNode *> ToLook;
-  DenseSet<MDNode *> Visited;
+  SetVector<MDNode *> Visited;
 
   // Start by looking at the attachments we collected
   for (const auto &NMD : MDs)
-    if (NMD && !Visited.count(NMD))
+    if (NMD)
       ToLook.push_back(NMD);
 
   while (!ToLook.empty()) {
Index: llvm/test/tools/llvm-reduce/remove-dimetadata.ll
===================================================================
--- llvm/test/tools/llvm-reduce/remove-dimetadata.ll
+++ llvm/test/tools/llvm-reduce/remove-dimetadata.ll
@@ -1,6 +1,6 @@
 ; Test that llvm-reduce can remove uninteresting DI metadata from an IR file.
 ;
-; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=di-metadata --test %python --test-arg %p/Inputs/remove-dimetadata.py %s -o %t
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=di-metadata --test=FileCheck --test-arg=--check-prefix=CHECK-INTERESTINGNESS --test-arg=%s --test-arg=--input-file %s -o %t
 ; RUN: FileCheck <%t %s
 
 @global = global i32 0
@@ -30,5 +30,6 @@
 !16 = !{!17, !18}
 ; CHECK: elements: [[EL:![0-9]+]])
 ; CHECK: [[EL]] = !{!{{[0-9]+}}}
+; CHECK-INTERESTINGNESS: interesting
 !17 = !DIDerivedType(tag: DW_TAG_member, name: "interesting", scope: !14, file: !1, baseType: !13, size: 32, align: 32, flags: DIFlagPublic)
 !18 = !DIDerivedType(tag: DW_TAG_member, name: "uninteresting", scope: !14, file: !1, baseType: !13, size: 32, align: 32, offset: 32, flags: DIFlagPublic)
Index: llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
===================================================================
--- llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
+++ llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
@@ -2,9 +2,9 @@
 ; DICompileUnit and DISuprogram.
 ;
 ; RUN: llvm-reduce --delta-passes=di-metadata --abort-on-invalid-reduction --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
-; RUN: cat %t | FileCheck %s
+; RUN: FileCheck <%t --enable-var-scope %s
 
-; CHECK-INTERESTINGNESS: define void @test() !dbg
+; CHECK-INTERESTINGNESS: define void @test() !dbg [[SUBPROG:![0-9]+]]
 ; CHECK-INTERESTINGNESS: !llvm.module.flags = !{
 
 ; CHECK-INTERESTINGNESS: !llvm.dbg.cu = !{[[CU:.+]]}
@@ -12,6 +12,7 @@
 ; CHECK-INTERESTINGNESS-DAG: [[CU]] = distinct !DICompileUnit(language: DW_LANG_C99,{{.*}}, retainedTypes: [[TYPES:![0-9]+]]
 ; CHECK-INTERESTINGNESS-DAG: [[TYPES]] = !{[[T0:![0-9]+]]
 ; CHECK-INTERESTINGNESS-DAG: [[T0]] = !DIBasicType(name: "unsigned int",
+; CHECK-INTERESTINGNESS-DAG: [[SUBPROG]] = distinct !DISubprogram(name: "test",
 
 
 
Index: llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py
===================================================================
--- llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py
+++ /dev/null
@@ -1,8 +0,0 @@
-import sys
-
-input = open(sys.argv[1], "r")
-for line in input:
-  if "interesting" in line:
-    sys.exit(0)
-
-sys.exit(1)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135473.466132.patch
Type: text/x-patch
Size: 3442 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221007/03c07b76/attachment.bin>


More information about the llvm-commits mailing list