[llvm] b7dae83 - DeadMachineInstructionElim: Don't repeat per-function init

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 13 05:20:03 PDT 2022


Author: Matt Arsenault
Date: 2022-09-13T08:19:54-04:00
New Revision: b7dae832e61da1f8b48cce1715514cbd5809eb3f

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

LOG: DeadMachineInstructionElim: Don't repeat per-function init

This was happening for every iteration but only needs to be done once.

Added: 
    

Modified: 
    llvm/lib/CodeGen/DeadMachineInstructionElim.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp b/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
index d507ad857cc4..e36db43567c5 100644
--- a/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
+++ b/llvm/lib/CodeGen/DeadMachineInstructionElim.cpp
@@ -107,6 +107,13 @@ bool DeadMachineInstructionElim::isDead(const MachineInstr *MI) const {
 bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
   if (skipFunction(MF.getFunction()))
     return false;
+
+  MRI = &MF.getRegInfo();
+
+  const TargetSubtargetInfo &ST = MF.getSubtarget();
+  TII = ST.getInstrInfo();
+  LivePhysRegs.init(*ST.getRegisterInfo());
+
   bool AnyChanges = eliminateDeadMI(MF);
   while (AnyChanges && eliminateDeadMI(MF))
     ;
@@ -115,10 +122,6 @@ bool DeadMachineInstructionElim::runOnMachineFunction(MachineFunction &MF) {
 
 bool DeadMachineInstructionElim::eliminateDeadMI(MachineFunction &MF) {
   bool AnyChanges = false;
-  MRI = &MF.getRegInfo();
-  TII = MF.getSubtarget().getInstrInfo();
-
-  LivePhysRegs.init(*MF.getSubtarget().getRegisterInfo());
 
   // Loop over all instructions in all blocks, from bottom to top, so that it's
   // more likely that chains of dependent but ultimately dead instructions will


        


More information about the llvm-commits mailing list