llvm-project/llvm/test/Assembler/zero-input-phi.ll
Nikita Popov 5921bc4271 [LLParser] Allow zero-input phi nodes
Zero-input phi nodes are accepted by the verifier and bitcode reader,
but currently rejected by the IR parser. Allow them there as well.

Because phi nodes must have one entry for each predecessor, such
phis can only occur in blocks without predecessors, aka unreachable
code.

Usually, when removing the last predecessor from a block, we also
remove phi nodes in it. However, this is not possible for
invalidation reasons sometimes, which is why we ended up allowing
zero-entry phis at some point in the past. See 9eb2c0113dfe,
D92247 and PR48296 for context.

I've dropped the verifier unit test, because this is now covered
by the regular IR test.

This fixes at least part of https://github.com/llvm/llvm-project/issues/57446.

Differential Revision: https://reviews.llvm.org/D133000
2022-08-31 14:24:12 +02:00

20 lines
398 B
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S < %s | FileCheck %s
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
define void @dead_phi() {
; CHECK-LABEL: @dead_phi(
; CHECK-NEXT: entry:
; CHECK-NEXT: ret void
; CHECK: return:
; CHECK-NEXT: [[R:%.*]] = phi i32
; CHECK-NEXT: ret void
;
entry:
ret void
return:
%r = phi i32
ret void
}