[DebugInfo] Fix ARM/AArch64 prologue_end position. Related to D11268.
[oota-llvm.git] / lib / Target / ARM / ARMFrameLowering.cpp
index 966f0310f0b32bdb182037b7a5b4be8dd8be3b06..98655203a4fd48d88590f395f2c3aaf85fd9bb7f 100644 (file)
@@ -302,13 +302,17 @@ void ARMFrameLowering::emitPrologue(MachineFunction &MF,
          "This emitPrologue does not support Thumb1!");
   bool isARM = !AFI->isThumbFunction();
   unsigned Align = STI.getFrameLowering()->getStackAlignment();
-  unsigned ArgRegsSaveSize = AFI->getArgRegsSaveSize();
-  unsigned NumBytes = MFI->getStackSize();
-  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();
-  DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
-  unsigned FramePtr = RegInfo->getFrameRegister(MF);
-
-  // Determine the sizes of each callee-save spill areas and record which frame
+  unsigned ArgRegsSaveSize = AFI->getArgRegsSaveSize();\r
+  unsigned NumBytes = MFI->getStackSize();\r
+  const std::vector<CalleeSavedInfo> &CSI = MFI->getCalleeSavedInfo();\r
+\r
+  // Debug location must be unknown since the first debug location is used\r
+  // to determine the end of the prologue.\r
+  DebugLoc dl;\r
+  \r
+  unsigned FramePtr = RegInfo->getFrameRegister(MF);\r
+\r
+  // Determine the sizes of each callee-save spill areas and record which frame\r
   // belongs to which callee-save spill areas.
   unsigned GPRCS1Size = 0, GPRCS2Size = 0, DPRCSSize = 0;
   int FramePtrSpillFI = 0;
@@ -890,13 +894,12 @@ void ARMFrameLowering::emitPushInst(MachineBasicBlock &MBB,
                                     unsigned NumAlignedDPRCS2Regs,
                                     unsigned MIFlags) const {
   MachineFunction &MF = *MBB.getParent();
-  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
-
-  DebugLoc DL;
-  if (MI != MBB.end()) DL = MI->getDebugLoc();
-
-  SmallVector<std::pair<unsigned,bool>, 4> Regs;
-  unsigned i = CSI.size();
+  const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();\r
+\r
+  DebugLoc DL;\r
+\r
+  SmallVector<std::pair<unsigned,bool>, 4> Regs;\r
+  unsigned i = CSI.size();\r
   while (i != 0) {
     unsigned LastReg = 0;
     for (; i != 0; --i) {