[DebugInfo] Fix ARM/AArch64 prologue_end position. Related to D11268.
[oota-llvm.git] / lib / Target / Sparc / SparcFrameLowering.cpp
index b92450962f0b587d4476fb2fd0e2f54472ca7ed6..a9d22ccdae36ebf37afd64451229ed466cca11f8 100644 (file)
@@ -41,13 +41,13 @@ void SparcFrameLowering::emitSPAdjustment(MachineFunction &MF,
                                           MachineBasicBlock &MBB,
                                           MachineBasicBlock::iterator MBBI,
                                           int NumBytes,
-                                          unsigned ADDrr,
-                                          unsigned ADDri) const {
-
-  DebugLoc dl = (MBBI != MBB.end()) ? MBBI->getDebugLoc() : DebugLoc();
-  const SparcInstrInfo &TII =
-      *static_cast<const SparcInstrInfo *>(MF.getSubtarget().getInstrInfo());
-
+                                          unsigned ADDrr,\r
+                                          unsigned ADDri) const {\r
+\r
+  DebugLoc dl;\r
+  const SparcInstrInfo &TII =\r
+      *static_cast<const SparcInstrInfo *>(MF.getSubtarget().getInstrInfo());\r
+\r
   if (NumBytes >= -4096 && NumBytes < 4096) {
     BuildMI(MBB, MBBI, dl, TII.get(ADDri), SP::O6)
       .addReg(SP::O6).addImm(NumBytes);
@@ -93,7 +93,9 @@ void SparcFrameLowering::emitPrologue(MachineFunction &MF,
   const SparcRegisterInfo &RegInfo =
       *static_cast<const SparcRegisterInfo *>(MF.getSubtarget().getRegisterInfo());
   MachineBasicBlock::iterator MBBI = MBB.begin();
-  DebugLoc dl = MBBI != MBB.end() ? MBBI->getDebugLoc() : DebugLoc();
+  // Debug location must be unknown since the first debug location is used
+  // to determine the end of the prologue.
+  DebugLoc dl;
   bool NeedsStackRealignment = RegInfo.needsStackRealignment(MF);
 
   // FIXME: unfortunately, returning false from canRealignStack