[llvm] [DebugInfo] Don't apply is_stmt on MBB branches that preserve lines (PR #108251)
Jeremy Morse via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 4 08:55:15 PST 2024
================
@@ -2229,6 +2230,112 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
// Record beginning of function.
PrologEndLoc = emitInitialLocDirective(
*MF, Asm->OutStreamer->getContext().getDwarfCompileUnitID());
+
+ // For each MBB we try to determine whether and what source line is *always*
+ // the last stepped-on line before entering MBB. Such a line exists if every
+ // predecessor has an instruction with source line N, which is the last valid
+ // source line to be seen before entering MBB, and if N is the same for all
+ // predecessors. If this is true, and the first instruction with a valid
+ // source line in MBB also has source line N, then that instruction should
+ // *not* use is_stmt. Otherwise, the first instruction with a valid source
+ // line in MBB should always use is_stmt, since we may step to it from a
+ // different line.
+ ForceIsStmtInstrs.clear();
+
+ // First, collect the last stepped line for each MBB.
+ SmallDenseMap<std::pair<const MachineBasicBlock *, const MachineBasicBlock *>,
+ unsigned>
+ MBBExitLines;
+ const auto *TII = MF->getSubtarget().getInstrInfo();
+
+ // We only need to examine MBBs that could have is_stmt set by this logic.
+ // We use const_cast even though we won't actually modify MF, because some
+ // methods we need take a non-const MBB.
+ SetVector<MachineBasicBlock *> PredMBBsToExamine;
----------------
jmorse wrote:
`SmallSetVector` maybe?
https://github.com/llvm/llvm-project/pull/108251
More information about the llvm-commits
mailing list