@@ -2061,8 +2061,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20612061 unsigned LastAsmLine =
20622062 Asm->OutStreamer ->getContext ().getCurrentDwarfLoc ().getLine ();
20632063
2064- bool PrevInstInDiffBB = PrevInstBB && PrevInstBB != MI->getParent ();
2065- if (DL == PrevInstLoc && !PrevInstInDiffBB) {
2064+ bool PrevInstInSameSection =
2065+ (!PrevInstBB ||
2066+ PrevInstBB->getSectionID () == MI->getParent ()->getSectionID ());
2067+ if (DL == PrevInstLoc && PrevInstInSameSection) {
20662068 // If we have an ongoing unspecified location, nothing to do here.
20672069 if (!DL)
20682070 return ;
@@ -2091,7 +2093,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20912093 // possibly debug information; we want it to have a source location.
20922094 // - Instruction is at the top of a block; we don't want to inherit the
20932095 // location from the physically previous (maybe unrelated) block.
2094- if (UnknownLocations == Enable || PrevLabel || PrevInstInDiffBB) {
2096+ if (UnknownLocations == Enable || PrevLabel ||
2097+ (PrevInstBB && PrevInstBB != MI->getParent ())) {
20952098 // Preserve the file and column numbers, if we can, to save space in
20962099 // the encoded line table.
20972100 // Do not update PrevInstLoc, it remembers the last non-0 line.
@@ -2116,11 +2119,9 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
21162119 PrologEndLoc = DebugLoc ();
21172120 }
21182121 // If the line changed, we call that a new statement; unless we went to
2119- // line 0 and came back, in which case it is not a new statement. We also
2120- // mark is_stmt for the first non-0 line in each BB, in case a predecessor BB
2121- // ends with a different line.
2122+ // line 0 and came back, in which case it is not a new statement.
21222123 unsigned OldLine = PrevInstLoc ? PrevInstLoc.getLine () : LastAsmLine;
2123- if (DL.getLine () && ( DL.getLine () != OldLine || PrevInstInDiffBB) )
2124+ if (DL.getLine () && DL.getLine () != OldLine)
21242125 Flags |= DWARF2_FLAG_IS_STMT;
21252126
21262127 const MDNode *Scope = DL.getScope ();
0 commit comments