[llvm-branch-commits] [llvm] [MIR] Add missing noteNewVirtualRegister callbacks (PR #111634)

Akshat Oke via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Oct 14 01:31:07 PDT 2024


https://github.com/optimisan updated https://github.com/llvm/llvm-project/pull/111634

>From 4d77407b08def09e2ff8e5b87bbce46630271e50 Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 9 Oct 2024 05:01:22 +0000
Subject: [PATCH 1/2] [MIR] Add missing noteNewVirtualRegister callbacks

---
 llvm/lib/CodeGen/MIRParser/MIParser.cpp  | 1 +
 llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 9 +++++----
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index f1d3ce9a563406..7aaa0f409d5ef9 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1786,6 +1786,7 @@ bool MIParser::parseRegisterOperand(MachineOperand &Dest,
 
         MRI.setRegClassOrRegBank(Reg, static_cast<RegisterBank *>(nullptr));
         MRI.setType(Reg, Ty);
+        MRI.noteNewVirtualRegister(Reg);
       }
     }
   } else if (consumeIfPresent(MIToken::lparen)) {
diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index 0c8a3eb6c2d83d..f10a480f7e6160 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -652,10 +652,10 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
 bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
                                       const yaml::MachineFunction &YamlMF) {
   MachineFunction &MF = PFS.MF;
-  MachineRegisterInfo &RegInfo = MF.getRegInfo();
+  MachineRegisterInfo &MRI = MF.getRegInfo();
   assert(RegInfo.tracksLiveness());
   if (!YamlMF.TracksRegLiveness)
-    RegInfo.invalidateLiveness();
+    MRI.invalidateLiveness();
 
   SMDiagnostic Error;
   // Parse the virtual register information.
@@ -705,6 +705,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
                          FlagStringValue.Value + "'");
       Info.Flags.push_back(FlagValue);
     }
+    MRI.noteNewVirtualRegister(Info.VReg);
   }
 
   // Parse the liveins.
@@ -720,7 +721,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
         return error(Error, LiveIn.VirtualRegister.SourceRange);
       VReg = Info->VReg;
     }
-    RegInfo.addLiveIn(Reg, VReg);
+    MRI.addLiveIn(Reg, VReg);
   }
 
   // Parse the callee saved registers (Registers that will
@@ -733,7 +734,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
         return error(Error, RegSource.SourceRange);
       CalleeSavedRegisters.push_back(Reg);
     }
-    RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
+    MRI.setCalleeSavedRegs(CalleeSavedRegisters);
   }
 
   return false;

>From 9390926f0379ff4d4311c8ce797178677927601a Mon Sep 17 00:00:00 2001
From: Akshat Oke <Akshat.Oke at amd.com>
Date: Wed, 9 Oct 2024 06:22:10 +0000
Subject: [PATCH 2/2] unrename RegInfo: doesn't belong here

---
 llvm/lib/CodeGen/MIRParser/MIRParser.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
index f10a480f7e6160..10d3cdcf0c1ce1 100644
--- a/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIRParser.cpp
@@ -652,10 +652,10 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
 bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
                                       const yaml::MachineFunction &YamlMF) {
   MachineFunction &MF = PFS.MF;
-  MachineRegisterInfo &MRI = MF.getRegInfo();
+  MachineRegisterInfo &RegInfo = MF.getRegInfo();
   assert(RegInfo.tracksLiveness());
   if (!YamlMF.TracksRegLiveness)
-    MRI.invalidateLiveness();
+    RegInfo.invalidateLiveness();
 
   SMDiagnostic Error;
   // Parse the virtual register information.
@@ -705,7 +705,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
                          FlagStringValue.Value + "'");
       Info.Flags.push_back(FlagValue);
     }
-    MRI.noteNewVirtualRegister(Info.VReg);
+    RegInfo.noteNewVirtualRegister(Info.VReg);
   }
 
   // Parse the liveins.
@@ -721,7 +721,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
         return error(Error, LiveIn.VirtualRegister.SourceRange);
       VReg = Info->VReg;
     }
-    MRI.addLiveIn(Reg, VReg);
+    RegInfo.addLiveIn(Reg, VReg);
   }
 
   // Parse the callee saved registers (Registers that will
@@ -734,7 +734,7 @@ bool MIRParserImpl::parseRegisterInfo(PerFunctionMIParsingState &PFS,
         return error(Error, RegSource.SourceRange);
       CalleeSavedRegisters.push_back(Reg);
     }
-    MRI.setCalleeSavedRegs(CalleeSavedRegisters);
+    RegInfo.setCalleeSavedRegs(CalleeSavedRegisters);
   }
 
   return false;



More information about the llvm-branch-commits mailing list