Skip to content

Commit 6b90407

Browse files
committed
Remove Debug
Signed-off-by: Peter Rong <[email protected]>
1 parent 3932446 commit 6b90407

File tree

1 file changed

+2
-122
lines changed

1 file changed

+2
-122
lines changed

llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp

Lines changed: 2 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636
#include "llvm/Support/LEB128.h"
3737
#include "llvm/Support/Path.h"
3838
#include "llvm/Support/ThreadPool.h"
39-
#include <iostream>
4039
#include <vector>
4140

4241
namespace llvm {
@@ -2184,9 +2183,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
21842183
if (const DWARFDebugLine::LineTable *LT =
21852184
ObjFile.Dwarf->getLineTableForUnit(&Unit.getOrigUnit())) {
21862185
// Search through Prologue
2187-
StringRef ObjName = ObjFile.FileName;
2188-
llvm::outs() << "ObjName: " << ObjName << "\n";
2189-
bool ShouldDebug = ObjName.contains("METAAppGroup.m");
21902186

21912187
DWARFDebugLine::LineTable LineTable;
21922188

@@ -2212,18 +2208,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
22122208
for (size_t i = 0; i < LT->Rows.size(); i++)
22132209
InputRows.emplace_back(TrackedRow{LT->Rows[i], i, false});
22142210

2215-
if (ShouldDebug) {
2216-
llvm::outs() << "DEBUG: InputRows setup:\n";
2217-
for (size_t i = 0; i < InputRows.size(); i++) {
2218-
llvm::outs() << " [" << i << "] OriginalRowIndex: "
2219-
<< InputRows[i].OriginalRowIndex << ", Address: 0x"
2220-
<< llvm::format_hex(InputRows[i].Row.Address.Address, 16)
2221-
<< ", Line: " << InputRows[i].Row.Line
2222-
<< ", EndSequence: " << InputRows[i].Row.EndSequence
2223-
<< "\n";
2224-
}
2225-
}
2226-
22272211
// This vector is the output line table (still in TrackedRow form).
22282212
std::vector<TrackedRow> OutputRows;
22292213
OutputRows.reserve(InputRows.size());
@@ -2291,20 +2275,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
22912275
insertLineSequence(Seq, OutputRows);
22922276
}
22932277

2294-
if (ShouldDebug) {
2295-
llvm::outs() << "DEBUG: OutputRows after processing:\n";
2296-
for (size_t i = 0; i < OutputRows.size(); i++) {
2297-
llvm::outs() << " [" << i << "] OriginalRowIndex: "
2298-
<< OutputRows[i].OriginalRowIndex << ", Address: 0x"
2299-
<< llvm::format_hex(OutputRows[i].Row.Address.Address,
2300-
16)
2301-
<< ", Line: " << OutputRows[i].Row.Line
2302-
<< ", EndSequence: " << OutputRows[i].Row.EndSequence
2303-
<< ", isStartSeqInOutput: "
2304-
<< OutputRows[i].isStartSeqInOutput << "\n";
2305-
}
2306-
}
2307-
23082278
// Materialize the tracked rows into final DWARFDebugLine::Row objects.
23092279
LineTable.Rows.clear();
23102280
LineTable.Rows.reserve(OutputRows.size());
@@ -2339,15 +2309,6 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
23392309
LineTableMapping[Seq.StmtSeqOffset] = Seq.FirstRowIndex;
23402310
}
23412311

2342-
if (ShouldDebug) {
2343-
llvm::outs() << "DEBUG: LineTableMapping from parser:\n";
2344-
for (const auto &Entry : LineTableMapping) {
2345-
llvm::outs() << " StmtSeqOffset: 0x"
2346-
<< llvm::format_hex(Entry.first, 8)
2347-
<< " -> FirstRowIndex: " << Entry.second << "\n";
2348-
}
2349-
}
2350-
23512312
// Second, manually find sequence boundaries and match them to the
23522313
// sorted attributes to handle sequences the parser might have missed.
23532314
auto StmtAttrs = Unit.getStmtSeqListAttributes();
@@ -2356,27 +2317,12 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
23562317
return A.get() < B.get();
23572318
});
23582319

2359-
if (ShouldDebug) {
2360-
llvm::outs() << "DEBUG: Sorted StmtAttrs:\n";
2361-
for (const auto &Attr : StmtAttrs) {
2362-
llvm::outs() << " StmtSeqOffset: 0x"
2363-
<< llvm::format_hex(Attr.get(), 8) << "\n";
2364-
}
2365-
}
2366-
23672320
std::vector<size_t> SeqStartRows;
23682321
SeqStartRows.push_back(0);
23692322
for (size_t i = 0; i < LT->Rows.size() - 1; ++i)
23702323
if (LT->Rows[i].EndSequence)
23712324
SeqStartRows.push_back(i + 1);
23722325

2373-
if (ShouldDebug) {
2374-
llvm::outs() << "DEBUG: SeqStartRows:\n";
2375-
for (size_t i = 0; i < SeqStartRows.size(); ++i) {
2376-
llvm::outs() << " [" << i << "]: " << SeqStartRows[i] << "\n";
2377-
}
2378-
}
2379-
23802326
// While SeqOffToOrigRow parsed from CU could be the ground truth,
23812327
// e.g.
23822328
//
@@ -2438,44 +2384,22 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
24382384
SeqStartIdxValidAndSmallerThanNext()) {
24392385
SeqOffToOrigRow[StmtAttrs[StmtAttrIdx].get()] =
24402386
SeqStartRows[SeqStartIdx];
2441-
if (ShouldDebug) {
2442-
llvm::outs()
2443-
<< "DEBUG: Adding dummy mapping: StmtSeqOffset 0x"
2444-
<< llvm::format_hex(StmtAttrs[StmtAttrIdx].get(), 8)
2445-
<< " -> OrigRowIndex " << SeqStartRows[SeqStartIdx] << "\n";
2446-
}
24472387
++StmtAttrIdx;
24482388
++SeqStartIdx;
24492389
}
24502390
// One of the pointer points to the value at or past Next in the
24512391
// LineTableMapping, We move the pointer to re-align with the
24522392
// LineTableMapping
24532393
while (StmtIdxValidAndSmallerThanNext()) {
2454-
if (ShouldDebug) {
2455-
llvm::outs()
2456-
<< "DEBUG: Skipping StmtAttr: 0x"
2457-
<< llvm::format_hex(StmtAttrs[StmtAttrIdx].get(), 8)
2458-
<< "\n";
2459-
}
24602394
++StmtAttrIdx;
24612395
}
24622396
while (SeqStartIdxValidAndSmallerThanNext()) {
2463-
if (ShouldDebug) {
2464-
llvm::outs() << "DEBUG: Skipping SeqStartRow: "
2465-
<< SeqStartRows[SeqStartIdx] << "\n";
2466-
}
24672397
++SeqStartIdx;
24682398
}
24692399
// Use the LineTableMapping's result as the ground truth and move
24702400
// on.
24712401
if (NextSeqOff != DummyKey) {
24722402
SeqOffToOrigRow[NextSeqOff] = NextRow;
2473-
if (ShouldDebug) {
2474-
llvm::outs()
2475-
<< "DEBUG: Adding ground truth mapping: StmtSeqOffset 0x"
2476-
<< llvm::format_hex(NextSeqOff, 8) << " -> OrigRowIndex "
2477-
<< NextRow << "\n";
2478-
}
24792403
}
24802404
// It is possible that the first StmtAttrIdx/SeqStartIdx point to
24812405
// later entries in LineTableMapping. Therefore we only increment
@@ -2498,82 +2422,38 @@ void DWARFLinker::DIECloner::generateLineTableForUnit(CompileUnit &Unit) {
24982422
}
24992423
}
25002424

2501-
if (ShouldDebug) {
2502-
llvm::outs() << "DEBUG: Final SeqOffToOrigRow map:\n";
2503-
for (const auto &Entry : SeqOffToOrigRow) {
2504-
llvm::outs() << " StmtSeqOffset: 0x"
2505-
<< llvm::format_hex(Entry.first, 8)
2506-
<< " -> OrigRowIndex: " << Entry.second << "\n";
2507-
}
2508-
}
2509-
25102425
// Create a map of original row indices to new row indices.
25112426
DenseMap<size_t, size_t> OrigRowToNewRow;
25122427
for (size_t i = 0; i < OutputRows.size(); ++i)
25132428
OrigRowToNewRow[OutputRows[i].OriginalRowIndex] = i;
25142429

2515-
if (ShouldDebug) {
2516-
llvm::outs() << "DEBUG: OrigRowToNewRow map:\n";
2517-
for (const auto &Entry : OrigRowToNewRow) {
2518-
llvm::outs() << " OrigRowIndex: " << Entry.first
2519-
<< " -> NewRowIndex: " << Entry.second << "\n";
2520-
}
2521-
}
2522-
25232430
// Patch DW_AT_LLVM_stmt_sequence attributes in the compile unit DIE
25242431
// with the correct offset into the .debug_line section.
25252432
for (const auto &StmtSeq : Unit.getStmtSeqListAttributes()) {
25262433
uint64_t OrigStmtSeq = StmtSeq.get();
2527-
if (ShouldDebug) {
2528-
llvm::outs() << "DEBUG: Processing StmtSeq attribute with offset 0x"
2529-
<< llvm::format_hex(OrigStmtSeq, 8) << "\n";
2530-
}
2531-
25322434
// 1. Get the original row index from the stmt list offset.
25332435
auto OrigRowIter = SeqOffToOrigRow.find(OrigStmtSeq);
25342436
// Check whether we have an output sequence for the StmtSeq offset.
25352437
// Some sequences are discarded by the DWARFLinker if they are invalid
25362438
// (empty).
25372439
if (OrigRowIter == SeqOffToOrigRow.end()) {
2538-
if (ShouldDebug) {
2539-
llvm::outs() << "DEBUG: StmtSeq 0x"
2540-
<< llvm::format_hex(OrigStmtSeq, 8)
2541-
<< " not found in SeqOffToOrigRow, setting to "
2542-
"OrigOffsetMissing\n";
2543-
}
2544-
StmtSeq.set(OrigOffsetMissing);
2440+
StmtSeq.set(UINT64_MAX);
25452441
continue;
25462442
}
25472443
size_t OrigRowIndex = OrigRowIter->second;
2548-
if (ShouldDebug) {
2549-
llvm::outs() << "DEBUG: Found OrigRowIndex: " << OrigRowIndex
2550-
<< "\n";
2551-
}
2552-
25532444
// 2. Get the new row index from the original row index.
25542445
auto NewRowIter = OrigRowToNewRow.find(OrigRowIndex);
25552446
if (NewRowIter == OrigRowToNewRow.end()) {
25562447
// If the original row index is not found in the map, update the
25572448
// stmt_sequence attribute to the 'invalid offset' magic value.
2558-
if (ShouldDebug) {
2559-
llvm::outs() << "DEBUG: OrigRowIndex " << OrigRowIndex
2560-
<< " not found in OrigRowToNewRow, setting to "
2561-
"NewOffsetMissing\n";
2562-
}
2563-
StmtSeq.set(NewOffsetMissing);
2449+
StmtSeq.set(UINT64_MAX);
25642450
continue;
25652451
}
25662452

25672453
// 3. Get the offset of the new row in the output .debug_line section.
25682454
assert(NewRowIter->second < OutputRowOffsets.size() &&
25692455
"New row index out of bounds");
25702456
uint64_t NewStmtSeqOffset = OutputRowOffsets[NewRowIter->second];
2571-
if (ShouldDebug) {
2572-
llvm::outs() << "DEBUG: Found NewRowIndex: " << NewRowIter->second
2573-
<< ", setting to new offset 0x"
2574-
<< llvm::format_hex(NewStmtSeqOffset, 8) << "\n";
2575-
}
2576-
25772457
// 4. Patch the stmt_list attribute with the new offset.
25782458
StmtSeq.set(NewStmtSeqOffset);
25792459
}

0 commit comments

Comments
 (0)