[llvm-reduce] Fix di-metadata pass test failures
authorMatthew Voss <matthew.voss@sony.com>
Fri, 7 Oct 2022 19:00:22 +0000 (12:00 -0700)
committerMatthew Voss <matthew.voss@sony.com>
Fri, 7 Oct 2022 19:05:25 +0000 (12:05 -0700)
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.

Differential Revision: https://reviews.llvm.org/D135473

llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py [deleted file]
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

diff --git a/llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py b/llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py
deleted file mode 100644 (file)
index 9fc290c..0000000
+++ /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)
index 9c8630b..1ceeca8 100644 (file)
@@ -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 71cefaf..f82ef03 100644 (file)
@@ -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 @@ define void @main() !dbg !5 {
 !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 f874a48..474139e 100644 (file)
@@ -27,13 +27,13 @@ using namespace llvm;
 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()) {