[DebugInfo] Fix ARM/AArch64 prologue_end position. Related to D11268.
[oota-llvm.git] / lib / Target / AArch64 / AArch64FrameLowering.cpp
index cd5821f081c32726adf26392ab88bc31aa4935d3..6ccb959239e06f21f13a57ef6add87a1f8d3a84a 100644 (file)
@@ -284,13 +284,16 @@ void AArch64FrameLowering::emitPrologue(MachineFunction &MF,
       MF.getSubtarget().getRegisterInfo());
   const TargetInstrInfo *TII = MF.getSubtarget().getInstrInfo();
   MachineModuleInfo &MMI = MF.getMMI();
-  AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();
-  bool needsFrameMoves = MMI.hasDebugInfo() || Fn->needsUnwindTableEntry();
-  bool HasFP = hasFP(MF);
-  DebugLoc DL = MBB.findDebugLoc(MBBI);
-
-  // All calls are tail calls in GHC calling conv, and functions have no
-  // prologue/epilogue.
+  AArch64FunctionInfo *AFI = MF.getInfo<AArch64FunctionInfo>();\r
+  bool needsFrameMoves = MMI.hasDebugInfo() || Fn->needsUnwindTableEntry();\r
+  bool HasFP = hasFP(MF);\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
+  // All calls are tail calls in GHC calling conv, and functions have no\r
+  // prologue/epilogue.\r
   if (MF.getFunction()->getCallingConv() == CallingConv::GHC)
     return;
 
@@ -727,15 +730,12 @@ bool AArch64FrameLowering::spillCalleeSavedRegisters(
   MachineFunction &MF = *MBB.getParent();
   const TargetInstrInfo &TII = *MF.getSubtarget().getInstrInfo();
   unsigned Count = CSI.size();
-  DebugLoc DL;
-  assert((Count & 1) == 0 && "Odd number of callee-saved regs to spill!");
-
-  if (MI != MBB.end())
-    DL = MI->getDebugLoc();
-
-  for (unsigned i = 0; i < Count; i += 2) {
-    unsigned idx = Count - i - 2;
-    unsigned Reg1 = CSI[idx].getReg();
+  DebugLoc DL;\r
+  assert((Count & 1) == 0 && "Odd number of callee-saved regs to spill!");\r
+\r
+  for (unsigned i = 0; i < Count; i += 2) {\r
+    unsigned idx = Count - i - 2;\r
+    unsigned Reg1 = CSI[idx].getReg();\r
     unsigned Reg2 = CSI[idx + 1].getReg();
     // GPRs and FPRs are saved in pairs of 64-bit regs. We expect the CSI
     // list to come in sorted by frame index so that we can issue the store