@@ -2228,26 +2228,15 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
2228
2228
PrologEndLoc = emitInitialLocDirective (
2229
2229
*MF, Asm->OutStreamer ->getContext ().getDwarfCompileUnitID ());
2230
2230
2231
- // Try to determine what line we would be stepped on before entering each MBB.
2232
- // This happens in the following ways:
2233
- // - If this block has a single predecessor, we determine the last line in
2234
- // the pred block and we have stepped from that.
2235
- // - If this block has multiple predecessors, we determine the last line in
2236
- // each of them; if they all agree then we have stepped from that line,
2237
- // otherwise we do not know what line we have stepped from.
2238
- // The last line in each MBB is determined as follows:
2239
- // - If the block contains at least one DebugLoc, we have stepped from the
2240
- // last one.
2241
- // - Otherwise, the last line is line 0.
2242
- // There is one extra rule however: if a predecessor branches to the current
2243
- // basic block, we only count DebugLocs on or before that branch, so if we're
2244
- // looking at the MBB %bb.0, which ends with:
2245
- // JCC_1 %bb.1, 0, !debug-location !1
2246
- // JMP_1 %bb.2, !debug-location !2
2247
- // We would consider !1 to be the last loc before %bb.1, and !2 before %bb.2.
2248
- // We also don't need to make this calculation for any block that doesn't have
2249
- // a non-0 line number on its first instruction, as we will always emit line 0
2250
- // without is_stmt for that block regardless.
2231
+ // For each MBB we try to determine whether and what source line is *always*
2232
+ // the last stepped-on line before entering MBB. Such a line exists if every
2233
+ // predecessor has an instruction with source line N, which is the last valid
2234
+ // source line to be seen before entering MBB, and if N is the same for all
2235
+ // predecessors. If this is true, and the first instruction with a valid
2236
+ // source line in MBB also has source line N, then that instruction should
2237
+ // *not* use is_stmt. Otherwise, the first instruction with a valid source
2238
+ // line in MBB should always use is_stmt, since we may step to it from a
2239
+ // different line.
2251
2240
ForceIsStmtInstrs.clear ();
2252
2241
2253
2242
// First, collect the last stepped line for each MBB.
@@ -2266,20 +2255,18 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
2266
2255
continue ;
2267
2256
for (auto &MI : MBB) {
2268
2257
if (MI.getDebugLoc () && MI.getDebugLoc ()->getLine ()) {
2269
- for (auto Pred : MBB.predecessors ())
2270
- PredMBBsToExamine.insert (&* Pred);
2258
+ for (auto * Pred : MBB.predecessors ())
2259
+ PredMBBsToExamine.insert (Pred);
2271
2260
PotentialIsStmtMBBInstrs.insert ({&MBB, &MI});
2272
2261
break ;
2273
2262
}
2274
2263
}
2275
2264
}
2276
2265
2277
2266
// For each predecessor MBB, we examine the last DebugLoc seen before each
2278
- // branch or logical fallthrough. We're generous with applying is_stmt; if
2267
+ // branch or logical fallthrough. We're generous with applying is_stmt: if
2279
2268
// there's an edge that TargetInstrInfo::analyzeBranch can't understand, we
2280
- // simply assume that is_stmt ought to be applied to the successors, since
2281
- // this rule is mainly intended to avoid excessive stepping on lines that
2282
- // expand to many lines of code.
2269
+ // assume that all successor MBBs use the last DebugLoc seen.
2283
2270
for (auto *MBB : PredMBBsToExamine) {
2284
2271
auto CheckMBBEdge = [&](MachineBasicBlock *Succ, unsigned OutgoingLine) {
2285
2272
auto MBBInstrIt = PotentialIsStmtMBBInstrs.find (Succ);
@@ -2312,7 +2299,6 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
2312
2299
unsigned FBBLine = MBB->back ().getDebugLoc ()->getLine ();
2313
2300
assert (MIIt->isBranch () && " Bad result from analyzeBranch?" );
2314
2301
CheckMBBEdge (FBB, FBBLine);
2315
- FBB = nullptr ;
2316
2302
++MIIt;
2317
2303
SuccessorBBs.push_back (TBB);
2318
2304
} else {
@@ -2344,7 +2330,7 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
2344
2330
}
2345
2331
++MIIt;
2346
2332
}
2347
- for (auto Succ : SuccessorBBs)
2333
+ for (auto * Succ : SuccessorBBs)
2348
2334
CheckMBBEdge (Succ, LastLine);
2349
2335
}
2350
2336
}
0 commit comments