[llvm] fe50eac - [llvm-reduce] Fix di-metadata pass test failures

Matthew Voss via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 7 12:05:44 PDT 2022


Author: Matthew Voss
Date: 2022-10-07T12:05:25-07:00
New Revision: fe50eac85c06b1f97fba4c0540cea84f4b9bac8d

URL: https://github.com/llvm/llvm-project/commit/fe50eac85c06b1f97fba4c0540cea84f4b9bac8d
DIFF: https://github.com/llvm/llvm-project/commit/fe50eac85c06b1f97fba4c0540cea84f4b9bac8d.diff

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

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

Added: 
    

Modified: 
    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

Removed: 
    llvm/test/tools/llvm-reduce/Inputs/remove-dimetadata.py


################################################################################
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
index 9fc290c8f26c..000000000000
--- a/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)

diff  --git a/llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll b/llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
index 9c8630be462e..1ceeca8b6561 100644
--- a/llvm/test/tools/llvm-reduce/remove-debug-info-nodes.ll
+++ b/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",
 
 
 

diff  --git a/llvm/test/tools/llvm-reduce/remove-dimetadata.ll b/llvm/test/tools/llvm-reduce/remove-dimetadata.ll
index 71cefaf17363..f82ef03ebdb4 100644
--- a/llvm/test/tools/llvm-reduce/remove-dimetadata.ll
+++ b/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 @@ 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)

diff  --git a/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
index f874a48b4306..474139e30fd6 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp
@@ -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()) {


        


More information about the llvm-commits mailing list