@@ -2061,8 +2061,10 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
2061
2061
unsigned LastAsmLine =
2062
2062
Asm->OutStreamer ->getContext ().getCurrentDwarfLoc ().getLine ();
2063
2063
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) {
2066
2068
// If we have an ongoing unspecified location, nothing to do here.
2067
2069
if (!DL)
2068
2070
return ;
@@ -2091,7 +2093,8 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
2091
2093
// possibly debug information; we want it to have a source location.
2092
2094
// - Instruction is at the top of a block; we don't want to inherit the
2093
2095
// location from the physically previous (maybe unrelated) block.
2094
- if (UnknownLocations == Enable || PrevLabel || PrevInstInDiffBB) {
2096
+ if (UnknownLocations == Enable || PrevLabel ||
2097
+ (PrevInstBB && PrevInstBB != MI->getParent ())) {
2095
2098
// Preserve the file and column numbers, if we can, to save space in
2096
2099
// the encoded line table.
2097
2100
// Do not update PrevInstLoc, it remembers the last non-0 line.
@@ -2116,11 +2119,9 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
2116
2119
PrologEndLoc = DebugLoc ();
2117
2120
}
2118
2121
// 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.
2122
2123
unsigned OldLine = PrevInstLoc ? PrevInstLoc.getLine () : LastAsmLine;
2123
- if (DL.getLine () && ( DL.getLine () != OldLine || PrevInstInDiffBB) )
2124
+ if (DL.getLine () && DL.getLine () != OldLine)
2124
2125
Flags |= DWARF2_FLAG_IS_STMT;
2125
2126
2126
2127
const MDNode *Scope = DL.getScope ();
0 commit comments