[llvm] [GlobalISel] Make IRTranslator able to handle PHIs with empty types. (PR #73235)

Dávid Ferenc Szabó via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 9 05:12:08 PST 2024


https://github.com/dfszabo updated https://github.com/llvm/llvm-project/pull/73235

>From 5756d089235a761bc900b0400cd55ae1dc64e029 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?D=C3=A1vid=20Ferenc=20Szab=C3=B3?=
 <szabodavidferenc at gmail.com>
Date: Thu, 23 Nov 2023 13:11:26 +0100
Subject: [PATCH] [GlobalISel] Make IRTranslator able to handle PHIs with empty
 types.

SelectionDAG already handle this since e53b7d1a11d180ed7b33190a837d8898ab2a0b71.
---
 llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp     |  2 ++
 .../AArch64/GlobalISel/phi-with-empty-type.ll    | 16 ++++++++++++++++
 2 files changed, 18 insertions(+)
 create mode 100644 llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll

diff --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 3753b6d540f1b3..c0b1b9c7cbcc74 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3118,6 +3118,8 @@ void IRTranslator::finishPendingPhis() {
 #endif // ifndef NDEBUG
   for (auto &Phi : PendingPHIs) {
     const PHINode *PI = Phi.first;
+    if (PI->getType()->isEmptyTy())
+      continue;
     ArrayRef<MachineInstr *> ComponentPHIs = Phi.second;
     MachineBasicBlock *PhiMBB = ComponentPHIs[0]->getParent();
     EntryBuilder->setDebugLoc(PI->getDebugLoc());
diff --git a/llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll b/llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll
new file mode 100644
index 00000000000000..57c2669fa3953f
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll
@@ -0,0 +1,16 @@
+; RUN: llc < %s -O0 -global-isel -mtriple=aarch64
+
+
+%zero = type [0 x i8]
+
+define %zero @test(%zero %x, %zero %y) {
+b1:
+  br i1 undef, label %end, label %b2
+
+b2:
+  br label %end
+
+end:
+  %z = phi %zero [ %y, %b1 ], [ %x, %b2 ]
+  ret %zero %z
+}



More information about the llvm-commits mailing list