Skip to content

Commit 843dae8

Browse files
committed
Update comments, remove unnecessary formatted code
1 parent 7813158 commit 843dae8

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,7 +2062,6 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20622062
unsigned LastAsmLine =
20632063
Asm->OutStreamer->getContext().getCurrentDwarfLoc().getLine();
20642064

2065-
<<<<<<< HEAD
20662065
if (!DL && MI == PrologEndLoc) {
20672066
// In rare situations, we might want to place the end of the prologue
20682067
// somewhere that doesn't have a source location already. It should be in
@@ -2073,11 +2072,9 @@ void DwarfDebug::beginInstruction(const MachineInstr *MI) {
20732072
return;
20742073
}
20752074

2076-
=======
20772075
bool PrevInstInSameSection =
20782076
(!PrevInstBB ||
20792077
PrevInstBB->getSectionID() == MI->getParent()->getSectionID());
2080-
>>>>>>> ac5931e8f979 (Re-add unnecessarily removed code)
20812078
bool ForceIsStmt = ForceIsStmtInstrs.contains(MI);
20822079
if (DL == PrevInstLoc && PrevInstInSameSection && !ForceIsStmt) {
20832080
// If we have an ongoing unspecified location, nothing to do here.
@@ -2319,26 +2316,40 @@ DwarfDebug::emitInitialLocDirective(const MachineFunction &MF, unsigned CUID) {
23192316
void DwarfDebug::findForceIsStmtInstrs(const MachineFunction *MF) {
23202317
ForceIsStmtInstrs.clear();
23212318

2322-
// Here we try to find MBBs where the last line stepped on before entering
2323-
// it is always the same, and which line that is. Such a line exists if every
2324-
// predecessor has an instruction with source line N, which is the last valid
2325-
// source line to be seen before entering MBB, and if N is the same for all
2326-
// predecessors. If this is true, and the first instruction with a valid
2327-
// source line in MBB also has source line N, then that instruction should
2328-
// *not* use is_stmt. Otherwise, the first instruction with a valid source
2329-
// line in MBB should always use is_stmt, since we may step to it from a
2330-
// different line.
2331-
// First, collect the last stepped line for each MBB.
2332-
SmallDenseMap<std::pair<const MachineBasicBlock *, const MachineBasicBlock *>,
2333-
unsigned>
2334-
MBBExitLines;
2319+
// For this function, we try to find MBBs where the last source line in every
2320+
// block predecessor matches the first line seen in the block itself; for
2321+
// every such MBB, we set is_stmt=false on the first line in the block, and
2322+
// for every other block we set is_stmt=true on the first line.
2323+
// For example, if we have the block %bb.3, which has 2 predecesors %bb.1 and
2324+
// %bb.2:
2325+
// bb.1:
2326+
// $r3 = MOV64ri 12, debug-location !DILocation(line: 4)
2327+
// JMP %bb.3, debug-location !DILocation(line: 5)
2328+
// bb.2:
2329+
// $r3 = MOV64ri 24, debug-location !DILocation(line: 5)
2330+
// JMP %bb.3
2331+
// bb.3:
2332+
// $r2 = MOV64ri 1
2333+
// $r1 = ADD $r2, $r3, debug-location !DILocation(line: 5)
2334+
// When we examine %bb.3, we first check to see if it contains any
2335+
// instructions with debug locations, and select the first such instruction;
2336+
// in this case, the ADD, with line=5. We then examine both of its
2337+
// predecessors to see what the last debug-location in them is. For each
2338+
// predecessor, if they do not contain any debug-locations, or if the last
2339+
// debug-location before jumping to %bb.3 does not have line=5, then the ADD
2340+
// in %bb.3 must use IsStmt. In this case, all predecessors have a
2341+
// debug-location with line=5 as the last debug-location before jumping to
2342+
// %bb.3, so we do not set is_stmt for the ADD instruction - we know that
2343+
// whichever MBB we have arrived from, the line has not changed.
2344+
23352345
const auto *TII = MF->getSubtarget().getInstrInfo();
23362346

2337-
// We only need to examine MBBs that could have is_stmt set by this logic.
2347+
// We only need to the predecessors of MBBs that could have is_stmt set by
2348+
// this logic.
2349+
SmallDenseSet<MachineBasicBlock *, 4> PredMBBsToExamine;
2350+
SmallDenseMap<MachineBasicBlock *, MachineInstr *> PotentialIsStmtMBBInstrs;
23382351
// We use const_cast even though we won't actually modify MF, because some
23392352
// methods we need take a non-const MBB.
2340-
SmallSetVector<MachineBasicBlock *, 4> PredMBBsToExamine;
2341-
SmallDenseMap<MachineBasicBlock *, MachineInstr *> PotentialIsStmtMBBInstrs;
23422353
for (auto &MBB : *const_cast<MachineFunction *>(MF)) {
23432354
if (MBB.empty() || MBB.pred_empty())
23442355
continue;
@@ -2352,10 +2363,11 @@ void DwarfDebug::findForceIsStmtInstrs(const MachineFunction *MF) {
23522363
}
23532364
}
23542365

2355-
// For each predecessor MBB, we examine the last DebugLoc seen before each
2356-
// branch or logical fallthrough. We're generous with applying is_stmt: if
2357-
// there's an edge that TargetInstrInfo::analyzeBranch can't understand, we
2358-
// assume that all successor MBBs use the last DebugLoc seen.
2366+
// For each predecessor MBB, we examine the last line seen before each branch
2367+
// or logical fallthrough. We use analyzeBranch to handle cases where
2368+
// different branches have different outgoing lines (i.e. if there are
2369+
// multiple branches that each have their own source location); otherwise we
2370+
// just use the last line in the block.
23592371
for (auto *MBB : PredMBBsToExamine) {
23602372
auto CheckMBBEdge = [&](MachineBasicBlock *Succ, unsigned OutgoingLine) {
23612373
auto MBBInstrIt = PotentialIsStmtMBBInstrs.find(Succ);
@@ -2440,8 +2452,7 @@ void DwarfDebug::beginFunctionImpl(const MachineFunction *MF) {
24402452
CurFn = MF;
24412453

24422454
auto *SP = MF->getFunction().getSubprogram();
2443-
assert(LScopes.empty() ||
2444-
SP == LScopes.getCurrentFunctionScope()->getScopeNode());
2455+
assert(LScopes.empty() || SP == LScopes.getCurrentFunctionScope()->getScopeNode());
24452456
if (SP->getUnit()->getEmissionKind() == DICompileUnit::NoDebug)
24462457
return;
24472458

0 commit comments

Comments
 (0)