Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2024

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Jun 17, 2024

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

Saying that a call preserves $noreg seems weird and required a
workaround in MachineLICM.
@llvmbot
Copy link
Member

llvmbot commented Jun 17, 2024

@llvm/pr-subscribers-llvm-regalloc

Author: Jay Foad (jayfoad)

Changes

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


Full diff: https://github.com/llvm/llvm-project/pull/95775.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/MachineLICM.cpp (+1-2)
  • (modified) llvm/lib/CodeGen/RegUsageInfoCollector.cpp (+3)
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))

@jayfoad jayfoad merged commit 457e895 into llvm:main Jun 17, 2024
6 of 8 checks passed
@jayfoad jayfoad deleted the regmask-noreg branch June 17, 2024 12:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants