[llvm-commits] [llvm] r116546 - in /llvm/trunk/lib/CodeGen: InlineSpiller.cpp LiveRangeEdit.cpp LiveRangeEdit.h SplitKit.cpp

Jakob Stoklund Olesen stoklund at 2pi.dk
Thu Oct 14 17:16:56 PDT 2010


Author: stoklund
Date: Thu Oct 14 19:16:55 2010
New Revision: 116546

URL: http://llvm.org/viewvc/llvm-project?rev=116546&view=rev
Log:
Move stack slot assignments into LiveRangeEdit.

All registers created during splitting or spilling are assigned to the same
stack slot as the parent register.

When splitting or rematting, we may not spill at all. In that case the stack
slot is still assigned, but it will be dead.

Modified:
    llvm/trunk/lib/CodeGen/InlineSpiller.cpp
    llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
    llvm/trunk/lib/CodeGen/LiveRangeEdit.h
    llvm/trunk/lib/CodeGen/SplitKit.cpp

Modified: llvm/trunk/lib/CodeGen/InlineSpiller.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/InlineSpiller.cpp?rev=116546&r1=116545&r2=116546&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/InlineSpiller.cpp (original)
+++ llvm/trunk/lib/CodeGen/InlineSpiller.cpp Thu Oct 14 19:16:55 2010
@@ -371,9 +371,7 @@
     return;
 
   rc_ = mri_.getRegClass(edit.getReg());
-  stackSlot_ = vrm_.getStackSlot(edit.getReg());
-  if (stackSlot_ == VirtRegMap::NO_STACK_SLOT)
-    stackSlot_ = vrm_.assignVirt2StackSlot(edit.getReg());
+  stackSlot_ = edit.assignStackSlot(vrm_);
 
   // Iterate over instructions using register.
   for (MachineRegisterInfo::reg_iterator RI = mri_.reg_begin(edit.getReg());

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp?rev=116546&r1=116545&r2=116546&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.cpp Thu Oct 14 19:16:55 2010
@@ -18,12 +18,21 @@
 
 using namespace llvm;
 
+int LiveRangeEdit::assignStackSlot(VirtRegMap &vrm) {
+  int ss = vrm.getStackSlot(getReg());
+  if (ss != VirtRegMap::NO_STACK_SLOT)
+    return ss;
+  return vrm.assignVirt2StackSlot(getReg());
+}
+
 LiveInterval &LiveRangeEdit::create(MachineRegisterInfo &mri,
                                     LiveIntervals &lis,
                                     VirtRegMap &vrm) {
   const TargetRegisterClass *RC = mri.getRegClass(parent_.reg);
   unsigned VReg = mri.createVirtualRegister(RC);
   vrm.grow();
+  // Immediately assign to the same stack slot as parent.
+  vrm.assignVirt2StackSlot(VReg, assignStackSlot(vrm));
   LiveInterval &li = lis.getOrCreateInterval(VReg);
   newRegs_.push_back(&li);
   return li;

Modified: llvm/trunk/lib/CodeGen/LiveRangeEdit.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/LiveRangeEdit.h?rev=116546&r1=116545&r2=116546&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/LiveRangeEdit.h (original)
+++ llvm/trunk/lib/CodeGen/LiveRangeEdit.h Thu Oct 14 19:16:55 2010
@@ -55,7 +55,12 @@
   iterator begin() const { return newRegs_.begin()+firstNew_; }
   iterator end() const { return newRegs_.end(); }
 
-  /// create - Create a new register with the same class as parentReg_.
+  /// assignStackSlot - Ensure a stack slot is assigned to parent.
+  /// @return the assigned stack slot number.
+  int assignStackSlot(VirtRegMap&);
+
+  /// create - Create a new register with the same class and stack slot as
+  /// parent.
   LiveInterval &create(MachineRegisterInfo&, LiveIntervals&, VirtRegMap&);
 
   /// allUsesAvailableAt - Return true if all registers used by OrigMI at

Modified: llvm/trunk/lib/CodeGen/SplitKit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SplitKit.cpp?rev=116546&r1=116545&r2=116546&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SplitKit.cpp (original)
+++ llvm/trunk/lib/CodeGen/SplitKit.cpp Thu Oct 14 19:16:55 2010
@@ -591,12 +591,6 @@
     openli_(lis_, *curli_)
 {
   assert(curli_ && "SplitEditor created from empty SplitAnalysis");
-
-  // Make sure curli_ is assigned a stack slot, so all our intervals get the
-  // same slot as curli_.
-  if (vrm_.getStackSlot(curli_->reg) == VirtRegMap::NO_STACK_SLOT)
-    vrm_.assignVirt2StackSlot(curli_->reg);
-
 }
 
 bool SplitEditor::intervalsLiveAt(SlotIndex Idx) const {





More information about the llvm-commits mailing list