[llvm-reduce] Update NoChunks initializer to be in line with AllChunks.
authorFlorian Hahn <flo@fhahn.com>
Wed, 21 Sep 2022 14:50:29 +0000 (15:50 +0100)
committerFlorian Hahn <flo@fhahn.com>
Wed, 21 Sep 2022 14:50:30 +0000 (15:50 +0100)
Without this patch, the assertion triggers below on the test case,
because we are using different oracles for the verification.

    Assertion failed: (Targets == NoChunksCounter.count() && "number of chunks changes when reducing"), function runDeltaPass, file Delta.cpp, line 272.

llvm/test/tools/llvm-reduce/remove-bbs-unreachable.ll [new file with mode: 0644]
llvm/tools/llvm-reduce/deltas/Delta.cpp

diff --git a/llvm/test/tools/llvm-reduce/remove-bbs-unreachable.ll b/llvm/test/tools/llvm-reduce/remove-bbs-unreachable.ll
new file mode 100644 (file)
index 0000000..385cf80
--- /dev/null
@@ -0,0 +1,22 @@
+; Check that verification doesn't fail when reducing a function with
+; unreachable blocks.
+;
+; RUN: llvm-reduce --abort-on-invalid-reduction --delta-passes=basic-blocks --test FileCheck --test-arg --check-prefixes=CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t
+; RUN: cat %t | FileCheck %s
+
+; CHECK-INTERESTINGNESS: test
+
+; CHECK: define void @test() {
+; CHECK-NEXT:   unreachable:
+; CHECK-NEXT:     ret void
+
+define void @test() {
+entry:
+  br label %exit
+
+unreachable:                                        ; No predecessors!
+  br label %exit
+
+exit:
+  ret void
+}
index 8d0a4c6..e8224ca 100644 (file)
@@ -263,7 +263,7 @@ void llvm::runDeltaPass(TestRunner &Test,
 
 #ifndef NDEBUG
     // Make sure that the number of chunks does not change as we reduce.
-    std::vector<Chunk> NoChunks;
+    std::vector<Chunk> NoChunks = {{0, INT_MAX}};
     Oracle NoChunksCounter(NoChunks);
     std::unique_ptr<ReducerWorkItem> Clone =
         cloneReducerWorkItem(Test.getProgram(), Test.getTargetMachine());