llvm-project/llvm/test/tools/llvm-reduce/reduce-bb-unreachable-does-not-dominate-error2.ll
Matt Arsenault 45a91c1521 llvm-reduce: Fix block reduction with unreachable blocks
Previously this would produce many invalid reductions with
"Instruction does not dominate uses" verifier errors.

This fixes issues in cases where the incoming IR
has unreachable blocks, and the resulting reduction
introduced new reachable blocks.

Have basic-blocks skip functions that have unreachable
blocks, Introduce a separate reduction which only
deletes unreachable blocks. Cleanup any newly unreachable
blocks after trimming out the requested deletions.

Includes a variety of meta-reduced tests for llvm-reduce
itself with -abort-on-invalid-reduction that were failing
on different iterations of this patch.

Bugpoint's implementation is much simpler (but currently I don't
understand how it avoids disconnecting interesting blocks from the CFG).
2022-10-28 17:07:26 -07:00

48 lines
1.4 KiB
LLVM

; 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: FileCheck %s < %t
; Make sure an invalid reduction isn't produced due to leaving behind
; invalid code in %bb8 after it becomes unreachable.
; CHECK-INTERESTINGNESS: store i32 0,
; CHECK-INTERESTINGNESS: store i32 1,
; CHECK-INTERESTINGNESS: store i32 2,
; CHECK: bb:
; CHECK-NEXT: store i32 0, ptr addrspace(3) null, align 4
; CHECK: bb6: ; preds = %bb8, %bb
; CHECK-NEXT: store i32 1, ptr addrspace(3) null, align 4
; CHECK: bb8: ; preds = %bb6
; CHECK-NEXT: %tmp = phi ptr addrspace(5) [ null, %bb6 ]
define amdgpu_kernel void @foo(i32 %arg) {
bb:
store i32 0, ptr addrspace(3) null
br label %bb6
bb6: ; preds = %bb10, %bb9, %bb8, %bb
store i32 1, ptr addrspace(3) null
switch i32 0, label %bb7 [
i32 0, label %bb8
]
bb7: ; preds = %bb6
unreachable
bb8: ; preds = %bb6
%tmp = phi ptr addrspace(5) [ null, %bb6 ]
store i32 2, ptr addrspace(5) %tmp
switch i32 %arg, label %bb6 [
i32 0, label %bb10
i32 1, label %bb9
]
bb9: ; preds = %bb8
br label %bb6
bb10: ; preds = %bb8
br label %bb6
}