[llvm] [RegAlloc] Remove redundant parameters for weightCalcHelper (NFC). (PR #170151)

via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 1 07:27:58 PST 2025


https://github.com/hstk30-hw created https://github.com/llvm/llvm-project/pull/170151

Since futureWeight was removed by
145cc9db2b442fc0533e275b92943a9894e33337, there is no more calls to weightCalcHelper(LI, start, end)

>From 1978efc8a1fe93d7d612b67d1da8c3331590f8cb Mon Sep 17 00:00:00 2001
From: hstk30 <hanwei62 at huawei.com>
Date: Mon, 1 Dec 2025 23:25:32 +0800
Subject: [PATCH] [RegAlloc] Remove redundant parameters for weightCalcHelper
 (NFC).

Since futureWeight was removed by
145cc9db2b442fc0533e275b92943a9894e33337, there is no more calls to
weightCalcHelper(LI, start, end)
---
 llvm/include/llvm/CodeGen/CalcSpillWeights.h |  9 +----
 llvm/lib/CodeGen/CalcSpillWeights.cpp        | 38 ++------------------
 2 files changed, 4 insertions(+), 43 deletions(-)

diff --git a/llvm/include/llvm/CodeGen/CalcSpillWeights.h b/llvm/include/llvm/CodeGen/CalcSpillWeights.h
index 11d1c16561507..dc2725e970dbe 100644
--- a/llvm/include/llvm/CodeGen/CalcSpillWeights.h
+++ b/llvm/include/llvm/CodeGen/CalcSpillWeights.h
@@ -97,15 +97,8 @@ class VirtRegMap;
     /// start and end - compute future expected spill weight of a split
     /// artifact of LI that will span between start and end slot indexes.
     /// \param LI     The live interval for which to compute the weight.
-    /// \param Start  The expected beginning of the split artifact. Instructions
-    ///               before start will not affect the weight. Relevant for
-    ///               weight calculation of future split artifact.
-    /// \param End    The expected end of the split artifact. Instructions
-    ///               after end will not affect the weight. Relevant for
-    ///               weight calculation of future split artifact.
     /// \return The spill weight. Returns negative weight for unspillable LI.
-    float weightCalcHelper(LiveInterval &LI, SlotIndex *Start = nullptr,
-                           SlotIndex *End = nullptr);
+    float weightCalcHelper(LiveInterval &LI);
 
     /// Weight normalization function.
     virtual float normalize(float UseDefFreq, unsigned Size,
diff --git a/llvm/lib/CodeGen/CalcSpillWeights.cpp b/llvm/lib/CodeGen/CalcSpillWeights.cpp
index a77da01761579..51cce4eb78c94 100644
--- a/llvm/lib/CodeGen/CalcSpillWeights.cpp
+++ b/llvm/lib/CodeGen/CalcSpillWeights.cpp
@@ -229,8 +229,7 @@ static bool canMemFoldInlineAsm(LiveInterval &LI,
   return false;
 }
 
-float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
-                                       SlotIndex *End) {
+float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI) {
   MachineRegisterInfo &MRI = MF.getRegInfo();
   const TargetRegisterInfo &TRI = *MF.getSubtarget().getRegisterInfo();
   const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
@@ -255,29 +254,6 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
   // Don't recompute spill weight for an unspillable register.
   bool IsSpillable = LI.isSpillable();
 
-  bool IsLocalSplitArtifact = Start && End;
-
-  // Do not update future local split artifacts.
-  bool ShouldUpdateLI = !IsLocalSplitArtifact;
-
-  if (IsLocalSplitArtifact) {
-    MachineBasicBlock *LocalMBB = LIS.getMBBFromIndex(*End);
-    assert(LocalMBB == LIS.getMBBFromIndex(*Start) &&
-           "start and end are expected to be in the same basic block");
-
-    // Local split artifact will have 2 additional copy instructions and they
-    // will be in the same BB.
-    // localLI = COPY other
-    // ...
-    // other   = COPY localLI
-    TotalWeight +=
-        LiveIntervals::getSpillWeight(true, false, &MBFI, LocalMBB, PSI);
-    TotalWeight +=
-        LiveIntervals::getSpillWeight(false, true, &MBFI, LocalMBB, PSI);
-
-    NumInstr += 2;
-  }
-
   // CopyHint is a sortable hint derived from a COPY instruction.
   struct CopyHint {
     Register Reg;
@@ -306,12 +282,6 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
        I != E;) {
     MachineInstr *MI = &*(I++);
 
-    // For local split artifacts, we are interested only in instructions between
-    // the expected start and end of the range.
-    SlotIndex SI = LIS.getInstructionIndex(*MI);
-    if (IsLocalSplitArtifact && ((SI < *Start) || (SI > *End)))
-      continue;
-
     NumInstr++;
     bool identityCopy = false;
     auto DestSrc = TII.isCopyInstr(*MI);
@@ -366,7 +336,7 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
   }
 
   // Pass all the sorted copy hints to mri.
-  if (ShouldUpdateLI && Hint.size()) {
+  if (Hint.size()) {
     // Remove a generic hint if previously added by target.
     if (TargetHint.first == 0 && TargetHint.second)
       MRI.clearSimpleHint(LI.reg());
@@ -400,7 +370,7 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
   // At the same time STATEPOINT instruction is perfectly fine to have this
   // operand on stack, so spilling such interval and folding its load from stack
   // into instruction itself makes perfect sense.
-  if (ShouldUpdateLI && LI.isZeroLength(LIS.getSlotIndexes()) &&
+  if (LI.isZeroLength(LIS.getSlotIndexes()) &&
       !LI.isLiveAtIndexes(LIS.getRegMaskSlots()) &&
       !isLiveAtStatepointVarArg(LI) && !canMemFoldInlineAsm(LI, MRI)) {
     LI.markNotSpillable();
@@ -418,7 +388,5 @@ float VirtRegAuxInfo::weightCalcHelper(LiveInterval &LI, SlotIndex *Start,
   const TargetRegisterClass *RC = MRI.getRegClass(LI.reg());
   TotalWeight *= TRI.getSpillWeightScaleFactor(RC);
 
-  if (IsLocalSplitArtifact)
-    return normalize(TotalWeight, Start->distance(*End), NumInstr);
   return normalize(TotalWeight, LI.getSize(), NumInstr);
 }



More information about the llvm-commits mailing list