Revert "[X86] Fix a variable name for r237977 so that it works with every compilers."
[oota-llvm.git] / lib / Target / X86 / X86RegisterInfo.cpp
index 6d031830b423e9652b319cf70ba93736ce698f54..06545bc209622a1997dbce268b51c715559b6d9f 100644 (file)
@@ -14,6 +14,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "X86RegisterInfo.h"
+#include "X86FrameLowering.h"
 #include "X86InstrBuilder.h"
 #include "X86MachineFunctionInfo.h"
 #include "X86Subtarget.h"
@@ -507,15 +508,14 @@ X86RegisterInfo::eliminateFrameIndex(MachineBasicBlock::iterator II,
   // offset is from the SP at the end of the prologue, not the FP location. This
   // matches the behavior of llvm.frameaddress.
   if (Opc == TargetOpcode::FRAME_ALLOC) {
-    assert(TFI->hasFP(MF) && "frame alloc requires FP");
     MachineOperand &FI = MI.getOperand(FIOperandNum);
-    const MachineFrameInfo *MFI = MF.getFrameInfo();
-    int Offset = MFI->getObjectOffset(FrameIndex) - TFI->getOffsetOfLocalArea();
     bool IsWinEH = MF.getTarget().getMCAsmInfo()->usesWindowsCFI();
+    int Offset;
     if (IsWinEH)
-      Offset += MFI->getStackSize();
+      Offset = static_cast<const X86FrameLowering *>(TFI)
+                     ->getFrameIndexOffsetFromSP(MF, FrameIndex);
     else
-      Offset += SlotSize;
+      Offset = TFI->getFrameIndexOffset(MF, FrameIndex);
     FI.ChangeToImmediate(Offset);
     return;
   }