[llvm] SPIRV: Set NoPHIs property after selection (PR #136327)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 23 13:14:13 PDT 2025


https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/136327

>From 552988051b0b15ca3bb0c6b98f61af46db852c7f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Fri, 18 Apr 2025 19:01:16 +0200
Subject: [PATCH 1/3] SPIRV: Set NoPHIs property after selection

There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.
---
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index 68286737b972f..f30578767a939 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -269,6 +269,12 @@ class SPIRVInstructionSelect : public InstructionSelect {
     return InstructionSelect::getRequiredProperties().reset(
         MachineFunctionProperties::Property::RegBankSelected);
   }
+
+  MachineFunctionProperties getClearedProperties() const override {
+    // No generic Phis remain, replaced with OpPhi
+    return InstructionSelect::getClearedProperties().reset(
+        MachineFunctionProperties::Property::NoPHIs);
+  }
 };
 } // namespace
 

>From 76f6ab8d5cc2274b2bf28ffa48e8747fd5470374 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 23 Apr 2025 12:11:35 +0200
Subject: [PATCH 2/3] SPIRV: Set NoPHIs property after rewriting them

There should be no PHIs after selection, as OpPhi is used
instead. This hopefully avoids errors in #135277.
---
 llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index 6e1c41d9f20cb..a6482d9df2ccb 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -2029,6 +2029,8 @@ static void patchPhis(const Module &M, SPIRVGlobalRegistry *GR,
                   {MachineOperand::CreateReg(ResTypeReg, false)});
       }
     }
+
+    MF->getProperties().set(MachineFunctionProperties::Property::NoPHIs);
   }
 }
 

>From 090b461ac7eb7d14e8ec8e441426697954f11279 Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 23 Apr 2025 22:13:54 +0200
Subject: [PATCH 3/3] Revert "SPIRV: Set NoPHIs property after selection"

This reverts commit 552988051b0b15ca3bb0c6b98f61af46db852c7f.
---
 llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
index f30578767a939..68286737b972f 100644
--- a/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVTargetMachine.cpp
@@ -269,12 +269,6 @@ class SPIRVInstructionSelect : public InstructionSelect {
     return InstructionSelect::getRequiredProperties().reset(
         MachineFunctionProperties::Property::RegBankSelected);
   }
-
-  MachineFunctionProperties getClearedProperties() const override {
-    // No generic Phis remain, replaced with OpPhi
-    return InstructionSelect::getClearedProperties().reset(
-        MachineFunctionProperties::Property::NoPHIs);
-  }
 };
 } // namespace
 



More information about the llvm-commits mailing list