Skip to content

Commit

Permalink
[InstCombine] Add test for code after non-terminator unreachable (NFC)
Browse files Browse the repository at this point in the history
  • Loading branch information
nikic committed Jun 22, 2023
1 parent 8aefa2b commit 893aa32
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions llvm/test/Transforms/InstCombine/unreachable-code.ll
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,40 @@ default:
call void @dummy()
ret void
}

define void @non_term_unreachable() {
; CHECK-LABEL: define void @non_term_unreachable() {
; CHECK-NEXT: store i1 true, ptr poison, align 1
; CHECK-NEXT: call void @dummy()
; CHECK-NEXT: ret void
;
store i1 true, ptr poison
call void @dummy()
ret void
}

define i32 @non_term_unreachable_phi(i1 %c) {
; CHECK-LABEL: define i32 @non_term_unreachable_phi
; CHECK-SAME: (i1 [[C:%.*]]) {
; CHECK-NEXT: entry:
; CHECK-NEXT: br i1 [[C]], label [[IF:%.*]], label [[JOIN:%.*]]
; CHECK: if:
; CHECK-NEXT: store i1 true, ptr poison, align 1
; CHECK-NEXT: call void @dummy()
; CHECK-NEXT: br label [[JOIN]]
; CHECK: join:
; CHECK-NEXT: [[PHI:%.*]] = phi i32 [ 1, [[IF]] ], [ 2, [[ENTRY:%.*]] ]
; CHECK-NEXT: ret i32 [[PHI]]
;
entry:
br i1 %c, label %if, label %join

if:
store i1 true, ptr poison
call void @dummy()
br label %join

join:
%phi = phi i32 [ 1, %if], [ 2, %entry ]
ret i32 %phi
}

0 comments on commit 893aa32

Please sign in to comment.