Clear up the last (famous last words) frame index value reuse issues for Thumb1.
authorJim Grosbach <grosbach@apple.com>
Wed, 10 Mar 2010 00:13:42 +0000 (00:13 +0000)
committerJim Grosbach <grosbach@apple.com>
Wed, 10 Mar 2010 00:13:42 +0000 (00:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@98109 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/PrologEpilogInserter.cpp
lib/CodeGen/PrologEpilogInserter.h
lib/Target/ARM/Thumb1RegisterInfo.cpp

index f50fd5a09bd2d51451671f4d21d3d0ad717175e8..2d54cd4274183a099e987487bf2da2d3b7e4307f 100644 (file)
@@ -57,6 +57,7 @@ bool PEI::runOnMachineFunction(MachineFunction &Fn) {
   const TargetRegisterInfo *TRI = Fn.getTarget().getRegisterInfo();
   RS = TRI->requiresRegisterScavenging(Fn) ? new RegScavenger() : NULL;
   FrameIndexVirtualScavenging = TRI->requiresFrameIndexScavenging(Fn);
+  FrameConstantRegMap.clear();
 
   // Get MachineModuleInfo so that we can track the construction of the
   // frame.
@@ -693,8 +694,7 @@ void PEI::replaceFrameIndices(MachineFunction &Fn) {
             assert (FrameIndexVirtualScavenging &&
                     "Not scavenging, but virtual returned from "
                     "eliminateFrameIndex()!");
-            FrameConstantRegMap[VReg] = FrameConstantEntry(Value.second,
-                                                           SPAdj);
+            FrameConstantRegMap[VReg] = FrameConstantEntry(Value, SPAdj);
           }
 
           // Reset the iterator if we were at the beginning of the BB.
@@ -765,12 +765,12 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) {
     unsigned CurrentVirtReg = 0;
     unsigned CurrentScratchReg = 0;
     bool havePrevValue = false;
-    int PrevValue = 0;
+    TargetRegisterInfo::FrameIndexValue PrevValue(0,0);
+    TargetRegisterInfo::FrameIndexValue Value(0,0);
     MachineInstr *PrevLastUseMI = NULL;
     unsigned PrevLastUseOp = 0;
     bool trackingCurrentValue = false;
     int SPAdj = 0;
-    int Value = 0;
 
     // The instruction stream may change in the loop, so check BB->end()
     // directly.
@@ -827,8 +827,11 @@ void PEI::scavengeFrameVirtualRegs(MachineFunction &Fn) {
             if (trackingCurrentValue) {
               SPAdj = (*Entry).second.second;
               Value = (*Entry).second.first;
-            } else
-              SPAdj = Value = 0;
+            } else {
+              SPAdj = 0;
+              Value.first = 0;
+              Value.second = 0;
+            }
 
             // If the scratch register from the last allocation is still
             // available, see if the value matches. If it does, just re-use it.
index 931f1eb231b278cbb7ff27bc6ad565023e57276b..aa95773596cfef28a8787c4276ebb88845627614 100644 (file)
@@ -102,7 +102,8 @@ namespace llvm {
     // When using the scavenger post-pass to resolve frame reference
     // materialization registers, maintain a map of the registers to
     // the constant value and SP adjustment associated with it.
-    typedef std::pair<int, int> FrameConstantEntry;
+    typedef std::pair<TargetRegisterInfo::FrameIndexValue, int>
+      FrameConstantEntry;
     DenseMap<unsigned, FrameConstantEntry> FrameConstantRegMap;
 
 #ifndef NDEBUG
index a4070bd4e17dc23297449d40efdabe4d3935dd8c..6215d2fa82c6f3ba11295ce73b3e39b4d7367a38 100644 (file)
@@ -642,7 +642,7 @@ Thumb1RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
       VReg = MF.getRegInfo().createVirtualRegister(ARM::tGPRRegisterClass);
       assert (Value && "Frame index virtual allocated, but Value arg is NULL!");
       bool UseRR = false;
-      bool TrackVReg = FrameReg == ARM::SP;
+      bool TrackVReg = true;
       Value->first = FrameReg; // use the frame register as a kind indicator
       Value->second = Offset;