Recalculate the spill weight and allocation hint for virtual registers created
authorJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 10 Aug 2010 17:07:22 +0000 (17:07 +0000)
committerJakob Stoklund Olesen <stoklund@2pi.dk>
Tue, 10 Aug 2010 17:07:22 +0000 (17:07 +0000)
during live range splitting.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@110686 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/CalcSpillWeights.h
lib/CodeGen/SplitKit.cpp
lib/CodeGen/SplitKit.h

index 99703a1c10a3323c9f01e0595a131fa071a4f1af..a47d8477393dede15641a41b1830b405f44fc3c1 100644 (file)
@@ -25,11 +25,11 @@ namespace llvm {
   class VirtRegAuxInfo {
     MachineFunction &mf_;
     LiveIntervals &lis_;
-    MachineLoopInfo &loops_;
+    const MachineLoopInfo &loops_;
     DenseMap<unsigned, float> hint_;
   public:
     VirtRegAuxInfo(MachineFunction &mf, LiveIntervals &lis,
-                   MachineLoopInfo &loops) :
+                   const MachineLoopInfo &loops) :
       mf_(mf), lis_(lis), loops_(loops) {}
 
     /// CalculateRegClass - recompute the register class for li from its uses.
index e6a7b70c7d6372a01213f7c30107b4cfc1c8cfcc..b7af73f627abc7568fd34e2d3745a5d551d0299d 100644 (file)
@@ -15,6 +15,7 @@
 #define DEBUG_TYPE "splitter"
 #include "SplitKit.h"
 #include "VirtRegMap.h"
+#include "llvm/CodeGen/CalcSpillWeights.h"
 #include "llvm/CodeGen/LiveIntervalAnalysis.h"
 #include "llvm/CodeGen/MachineFunctionPass.h"
 #include "llvm/CodeGen/MachineInstrBuilder.h"
@@ -566,8 +567,12 @@ void SplitEditor::rewrite() {
     intervals_.push_back(dupli_);
   }
 
-  // FIXME: *Calculate spill weights, allocation hints, and register classes for
-  // firstInterval..
+  // Calculate spill weight and allocation hints for new intervals.
+  VirtRegAuxInfo vrai(vrm_.getMachineFunction(), lis_, sa_.loops_);
+  for (unsigned i = firstInterval, e = intervals_.size(); i != e; ++i) {
+    LiveInterval &li = *intervals_[i];
+    vrai.CalculateWeightAndHint(li);
+  }
 }
 
 
index d5136877de62b90bb7bb915206eb4864b4518669..d125a4534370c94637145b6d06490caa24ebb76b 100644 (file)
@@ -31,11 +31,13 @@ class VNInfo;
 /// SplitAnalysis - Analyze a LiveInterval, looking for live range splitting
 /// opportunities.
 class SplitAnalysis {
+public:
   const MachineFunction &mf_;
   const LiveIntervals &lis_;
   const MachineLoopInfo &loops_;
   const TargetInstrInfo &tii_;
 
+private:
   // Current live interval.
   const LiveInterval *curli_;