Skip to content

Commit 0ff3d72

Browse files
authored
[GlobalISel] Make IRTranslator able to handle PHIs with empty types. (#73235)
SelectionDAG already handle this since e53b7d1.
1 parent 677ced8 commit 0ff3d72

File tree

2 files changed

+34
-0
lines changed

2 files changed

+34
-0
lines changed

llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3223,6 +3223,8 @@ void IRTranslator::finishPendingPhis() {
32233223
#endif // ifndef NDEBUG
32243224
for (auto &Phi : PendingPHIs) {
32253225
const PHINode *PI = Phi.first;
3226+
if (PI->getType()->isEmptyTy())
3227+
continue;
32263228
ArrayRef<MachineInstr *> ComponentPHIs = Phi.second;
32273229
MachineBasicBlock *PhiMBB = ComponentPHIs[0]->getParent();
32283230
EntryBuilder->setDebugLoc(PI->getDebugLoc());
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
2+
; RUN: llc < %s -O0 -global-isel -mtriple=aarch64 -stop-after=irtranslator | FileCheck %s
3+
4+
5+
%zero = type [0 x i8]
6+
7+
define %zero @test(%zero %x, %zero %y) {
8+
; CHECK-LABEL: name: test
9+
; CHECK: bb.1.b1:
10+
; CHECK-NEXT: successors: %bb.3(0x40000000), %bb.2(0x40000000)
11+
; CHECK-NEXT: {{ $}}
12+
; CHECK-NEXT: [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
13+
; CHECK-NEXT: G_BRCOND [[DEF]](s1), %bb.3
14+
; CHECK-NEXT: G_BR %bb.2
15+
; CHECK-NEXT: {{ $}}
16+
; CHECK-NEXT: bb.2.b2:
17+
; CHECK-NEXT: successors: %bb.3(0x80000000)
18+
; CHECK-NEXT: {{ $}}
19+
; CHECK-NEXT: G_BR %bb.3
20+
; CHECK-NEXT: {{ $}}
21+
; CHECK-NEXT: bb.3.end:
22+
; CHECK-NEXT: RET_ReallyLR
23+
b1:
24+
br i1 undef, label %end, label %b2
25+
26+
b2:
27+
br label %end
28+
29+
end:
30+
%z = phi %zero [ %y, %b1 ], [ %x, %b2 ]
31+
ret %zero %z
32+
}

0 commit comments

Comments
 (0)