Skip to content

Conversation

@hstk30-hw
Copy link
Contributor

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

Since futureWeight was removed by
145cc9d, there is no more calls to
weightCalcHelper(LI, start, end)
@llvmbot
Copy link
Member

llvmbot commented Dec 1, 2025

@llvm/pr-subscribers-llvm-regalloc

Author: None (hstk30-hw)

Changes

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


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

2 Files Affected:

  • (modified) llvm/include/llvm/CodeGen/CalcSpillWeights.h (+1-8)
  • (modified) llvm/lib/CodeGen/CalcSpillWeights.cpp (+3-35)
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);
 }

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.

2 participants