Distinquish stack slots from other stack objects. They (and fixed objects) get FixedS...
authorEvan Cheng <evan.cheng@apple.com>
Sat, 17 Oct 2009 09:20:14 +0000 (09:20 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Sat, 17 Oct 2009 09:20:14 +0000 (09:20 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@84326 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/MachineFrameInfo.h
lib/CodeGen/PreAllocSplitting.cpp
lib/CodeGen/PrologEpilogInserter.cpp
lib/CodeGen/RegAllocLocal.cpp
lib/CodeGen/VirtRegMap.cpp
lib/Target/ARM/ARMBaseInstrInfo.cpp
lib/Target/X86/X86InstrBuilder.h

index 99a4c3d07d9b188b6855cb7a8370a62db639bdb9..a04189c4364230c083137c9f6638a6956ad8a4cb 100644 (file)
@@ -102,8 +102,14 @@ class MachineFrameInfo {
     // default, fixed objects are immutable unless marked otherwise.
     bool isImmutable;
 
-    StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false)
-      : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM) {}
+    // isSpillSlot - If true, the stack object is used as spill slot. It
+    // cannot alias any other memory objects.
+    bool isSpillSlot;
+
+    StackObject(uint64_t Sz, unsigned Al, int64_t SP = 0, bool IM = false,
+                bool isSS = false)
+      : SPOffset(SP), Size(Sz), Alignment(Al), isImmutable(IM),
+        isSpillSlot(isSS) {}
   };
 
   /// Objects - The list of stack objects allocated...
@@ -352,6 +358,14 @@ public:
     return Objects[ObjectIdx+NumFixedObjects].isImmutable;
   }
 
+  /// isSpillSlotObjectIndex - Returns true if the specified index corresponds
+  /// to a spill slot..
+  bool isSpillSlotObjectIndex(int ObjectIdx) const {
+    assert(unsigned(ObjectIdx+NumFixedObjects) < Objects.size() &&
+           "Invalid Object Idx!");
+    return Objects[ObjectIdx+NumFixedObjects].isSpillSlot;;
+  }
+
   /// isDeadObjectIndex - Returns true if the specified index corresponds to
   /// a dead object.
   bool isDeadObjectIndex(int ObjectIdx) const {
@@ -363,9 +377,9 @@ public:
   /// CreateStackObject - Create a new statically sized stack object, returning
   /// a nonnegative identifier to represent it.
   ///
-  int CreateStackObject(uint64_t Size, unsigned Alignment) {
+  int CreateStackObject(uint64_t Size, unsigned Alignment, bool isSS = false) {
     assert(Size != 0 && "Cannot allocate zero size stack objects!");
-    Objects.push_back(StackObject(Size, Alignment));
+    Objects.push_back(StackObject(Size, Alignment, 0, false, isSS));
     return (int)Objects.size()-NumFixedObjects-1;
   }
 
index 8fa07d4d9afc217f29c1960e09f4581f00bf1b94..726869a3fb6af4cefd638554e1756c3eb2a777f4 100644 (file)
@@ -952,7 +952,7 @@ MachineInstr* PreAllocSplitting::FoldSpill(unsigned vreg,
   if (I != IntervalSSMap.end()) {
     SS = I->second;
   } else {
-    SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment());    
+    SS = MFI->CreateStackObject(RC->getSize(), RC->getAlignment());
   }
   
   MachineInstr* FMI = TII->foldMemoryOperand(*MBB->getParent(),
index 7af0bba19735281740f06b9b0e14764e7b72504e..8a0b003e92cf330013d6dafcfcec492d06ecbbbb 100644 (file)
@@ -259,7 +259,7 @@ void PEI::calculateCalleeSavedRegisters(MachineFunction &Fn) {
       // the TargetRegisterClass if the stack alignment is smaller. Use the
       // min.
       Align = std::min(Align, StackAlign);
-      FrameIdx = FFI->CreateStackObject(RC->getSize(), Align);
+      FrameIdx = FFI->CreateStackObject(RC->getSize(), Align, true);
       if ((unsigned)FrameIdx < MinCSFrameIndex) MinCSFrameIndex = FrameIdx;
       if ((unsigned)FrameIdx > MaxCSFrameIndex) MaxCSFrameIndex = FrameIdx;
     } else {
index 6caa2d3b824fb6efcd6cdecb5851677139a46bcf..28ede5526b829ea1e5677a733497b6153a923e95 100644 (file)
@@ -263,7 +263,7 @@ int RALocal::getStackSpaceFor(unsigned VirtReg, const TargetRegisterClass *RC) {
 
   // Allocate a new stack object for this spill location...
   int FrameIdx = MF->getFrameInfo()->CreateStackObject(RC->getSize(),
-                                                       RC->getAlignment());
+                                                       RC->getAlignment(),true);
 
   // Assign the slot...
   StackSlotForVirtReg[VirtReg] = FrameIdx;
index c78f35bdb136abe23c1c436b5d6fc93c5e65e87a..cac098bacea81f784da3d559e2855acc42d1d4c3 100644 (file)
@@ -118,7 +118,7 @@ int VirtRegMap::assignVirt2StackSlot(unsigned virtReg) {
          "attempt to assign stack slot to already spilled register");
   const TargetRegisterClass* RC = MF->getRegInfo().getRegClass(virtReg);
   int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(),
-                                                RC->getAlignment());
+                                              RC->getAlignment(), /*isSS*/true);
   if (LowSpillSlot == NO_STACK_SLOT)
     LowSpillSlot = SS;
   if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot)
@@ -162,7 +162,7 @@ int VirtRegMap::getEmergencySpillSlot(const TargetRegisterClass *RC) {
   if (I != EmergencySpillSlots.end())
     return I->second;
   int SS = MF->getFrameInfo()->CreateStackObject(RC->getSize(),
-                                                RC->getAlignment());
+                                              RC->getAlignment(), /*isSS*/true);
   if (LowSpillSlot == NO_STACK_SLOT)
     LowSpillSlot = SS;
   if (HighSpillSlot == NO_STACK_SLOT || SS > HighSpillSlot)
index ecdf5a0be64365743958c223fad468eee865c7e5..271e0a92c0e14b14e5317436a8fddc6abedfc429 100644 (file)
@@ -670,8 +670,11 @@ storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
   MachineFunction &MF = *MBB.getParent();
   MachineFrameInfo &MFI = *MF.getFrameInfo();
 
+  const Value *SV = (MFI.isFixedObjectIndex(FI) ||
+                     MFI.isSpillSlotObjectIndex(FI))
+    ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack();
   MachineMemOperand *MMO =
-    MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI),
+    MF.getMachineMemOperand(SV,
                             MachineMemOperand::MOStore, 0,
                             MFI.getObjectSize(FI),
                             MFI.getObjectAlignment(FI));
@@ -708,8 +711,11 @@ loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator I,
   MachineFunction &MF = *MBB.getParent();
   MachineFrameInfo &MFI = *MF.getFrameInfo();
 
+  const Value *SV = (MFI.isFixedObjectIndex(FI) ||
+                     MFI.isSpillSlotObjectIndex(FI))
+    ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack();
   MachineMemOperand *MMO =
-    MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI),
+    MF.getMachineMemOperand(SV,
                             MachineMemOperand::MOLoad, 0,
                             MFI.getObjectSize(FI),
                             MFI.getObjectAlignment(FI));
index c475b56d12f457cd0ecbf824807761fca83da9aa..8cbdfec87dd84c2a2ecf64643275ca8ac89201c3 100644 (file)
@@ -143,8 +143,11 @@ addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset = 0) {
     Flags |= MachineMemOperand::MOLoad;
   if (TID.mayStore())
     Flags |= MachineMemOperand::MOStore;
+  const Value *SV = (MFI.isFixedObjectIndex(FI) ||
+                     MFI.isSpillSlotObjectIndex(FI))
+    ? PseudoSourceValue::getFixedStack(FI) : PseudoSourceValue::getStack();
   MachineMemOperand *MMO =
-    MF.getMachineMemOperand(PseudoSourceValue::getFixedStack(FI),
+    MF.getMachineMemOperand(SV,
                             Flags, Offset,
                             MFI.getObjectSize(FI),
                             MFI.getObjectAlignment(FI));