[llvm] [CodeGen] Do not include $noreg in any regmask operands. NFCI. (PR #95775)

Jay Foad via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 17 05:35:49 PDT 2024


https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/95775

Saying that a call preserves $noreg seems weird and required a
workaround in MachineLICM.


>From 7dd128f9ab3aa61a01c2ff543587d31d61626a98 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Mon, 17 Jun 2024 13:34:12 +0100
Subject: [PATCH] [CodeGen] Do not include $noreg in any regmask operands.
 NFCI.

Saying that a call preserves $noreg seems weird and required a
workaround in MachineLICM.
---
 llvm/lib/CodeGen/MachineLICM.cpp           | 3 +--
 llvm/lib/CodeGen/RegUsageInfoCollector.cpp | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/CodeGen/MachineLICM.cpp b/llvm/lib/CodeGen/MachineLICM.cpp
index 1c76d72ed5152..d81fe54fe844c 100644
--- a/llvm/lib/CodeGen/MachineLICM.cpp
+++ b/llvm/lib/CodeGen/MachineLICM.cpp
@@ -440,8 +440,7 @@ static void applyBitsNotInRegMaskToRegUnitsMask(const TargetRegisterInfo &TRI,
         break;
 
       // Check if we have a valid PhysReg that is set in the mask.
-      // FIXME: We shouldn't have to check for PhysReg.
-      if (PhysReg && ((Word >> Bit) & 1)) {
+      if ((Word >> Bit) & 1) {
         for (MCRegUnitIterator RUI(PhysReg, &TRI); RUI.isValid(); ++RUI)
           ClobberedRUs.reset(*RUI);
       }
diff --git a/llvm/lib/CodeGen/RegUsageInfoCollector.cpp b/llvm/lib/CodeGen/RegUsageInfoCollector.cpp
index 6657cf3c1ef4a..ca5e0b428c477 100644
--- a/llvm/lib/CodeGen/RegUsageInfoCollector.cpp
+++ b/llvm/lib/CodeGen/RegUsageInfoCollector.cpp
@@ -142,6 +142,9 @@ bool RegUsageInfoCollector::runOnMachineFunction(MachineFunction &MF) {
     RegMask[Reg / 32] &= ~(1u << Reg % 32);
   };
 
+  // Don't include $noreg in any regmasks.
+  SetRegAsDefined(MCRegister::NoRegister);
+
   // Some targets can clobber registers "inside" a call, typically in
   // linker-generated code.
   for (const MCPhysReg Reg : TRI->getIntraCallClobberedRegs(&MF))



More information about the llvm-commits mailing list