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

via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 15 08:26:37 PST 2024


Author: Dávid Ferenc Szabó
Date: 2024-01-15T23:26:30+07:00
New Revision: 0ff3d729f92b3878d48eb1179649d7bb5feecd02

URL: https://github.com/llvm/llvm-project/commit/0ff3d729f92b3878d48eb1179649d7bb5feecd02
DIFF: https://github.com/llvm/llvm-project/commit/0ff3d729f92b3878d48eb1179649d7bb5feecd02.diff

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

SelectionDAG already handle this since
e53b7d1a11d180ed7b33190a837d8898ab2a0b71.

Added: 
    llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll

Modified: 
    llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
index 8a6bfdc5ee669c..662de0f3fe0e5e 100644
--- a/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
+++ b/llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
@@ -3223,6 +3223,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..4aaa58e8dab2e0
--- /dev/null
+++ b/llvm/test/CodeGen/AArch64/GlobalISel/phi-with-empty-type.ll
@@ -0,0 +1,32 @@
+; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 4
+; RUN: llc < %s -O0 -global-isel -mtriple=aarch64 -stop-after=irtranslator | FileCheck %s
+
+
+%zero = type [0 x i8]
+
+define %zero @test(%zero %x, %zero %y) {
+  ; CHECK-LABEL: name: test
+  ; CHECK: bb.1.b1:
+  ; CHECK-NEXT:   successors: %bb.3(0x40000000), %bb.2(0x40000000)
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   [[DEF:%[0-9]+]]:_(s1) = G_IMPLICIT_DEF
+  ; CHECK-NEXT:   G_BRCOND [[DEF]](s1), %bb.3
+  ; CHECK-NEXT:   G_BR %bb.2
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.2.b2:
+  ; CHECK-NEXT:   successors: %bb.3(0x80000000)
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   G_BR %bb.3
+  ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT: bb.3.end:
+  ; CHECK-NEXT:   RET_ReallyLR
+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