Skip to content

Commit 1c08371

Browse files
committed
Rebased and addressed comments
1 parent 63ee4a3 commit 1c08371

File tree

4 files changed

+28
-16
lines changed

4 files changed

+28
-16
lines changed

bolt/include/bolt/Core/DebugData.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -858,14 +858,23 @@ class ClusteredRows {
858858
ArrayRef<DebugLineTableRowRef> getRows() const {
859859
return ArrayRef<DebugLineTableRowRef>(beginPtrConst(), Size);
860860
}
861+
862+
/// Returns the number of elements in the array.
861863
uint64_t size() const { return Size; }
864+
865+
/// We re-purpose SMLoc inside MCInst to store the pointer
866+
/// to ClusteredRows. fromSMLoc() and toSMLoc() are helper
867+
/// functions to convert between SMLoc and ClusteredRows.
868+
862869
static const ClusteredRows *fromSMLoc(const SMLoc &Loc) {
863870
return reinterpret_cast<const ClusteredRows *>(Loc.getPointer());
864871
}
865872
SMLoc toSMLoc() const {
866873
return SMLoc::getFromPointer(reinterpret_cast<const char *>(this));
867874
}
868875

876+
/// Given a vector of DebugLineTableRowRef, this method
877+
/// copies the elements into pre-allocated memory.
869878
template <typename T> void populate(const T Vec) {
870879
assert(Vec.size() == Size && "Sizes must match");
871880
DebugLineTableRowRef *CurRawPtr = beginPtr();
@@ -880,6 +889,8 @@ class ClusteredRows {
880889
DebugLineTableRowRef Rows;
881890

882891
ClusteredRows(uint64_t Size) : Size(Size) {}
892+
893+
/// Total size of the object including the array.
883894
static uint64_t getTotalSize(uint64_t Size) {
884895
assert(Size > 0 && "Size must be greater than 0");
885896
return sizeof(ClusteredRows) + (Size - 1) * sizeof(DebugLineTableRowRef);

bolt/lib/Core/BinaryContext.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,7 @@ void BinaryContext::preprocessDebugInfo() {
16981698
}
16991699
Function.addDWARFUnit(It->Unit);
17001700

1701-
// Go forward and add all units from ranges that cover the function
1701+
// Go forward and add all units from ranges that cover the function.
17021702
while (++It != AllRanges.end()) {
17031703
if (It->LowPC > FunctionAddress || FunctionAddress >= It->HighPC)
17041704
break;

bolt/lib/Core/BinaryEmitter.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class BinaryEmitter {
178178
/// marker in the line table program, but provides one to the DWARF generator
179179
/// when it needs it.
180180
void emitLineInfoEnd(const BinaryFunction &BF, MCSymbol *FunctionEndSymbol,
181-
DWARFUnit *Unit);
181+
const DWARFUnit &Unit);
182182

183183
/// Emit debug line info for unprocessed functions from CUs that include
184184
/// emitted functions.
@@ -439,7 +439,7 @@ bool BinaryEmitter::emitFunction(BinaryFunction &Function,
439439

440440
if (opts::UpdateDebugSections && !Function.getDWARFUnits().empty())
441441
for (const auto &[_, Unit] : Function.getDWARFUnits())
442-
emitLineInfoEnd(Function, EndSymbol, Unit);
442+
emitLineInfoEnd(Function, EndSymbol, *Unit);
443443

444444
// Exception handling info for the function.
445445
emitLSDA(Function, FF);
@@ -707,13 +707,14 @@ SMLoc BinaryEmitter::emitLineInfo(const BinaryFunction &BF, SMLoc NewLoc,
707707
CurrentRow.Discriminator);
708708
const MCDwarfLoc &DwarfLoc = BC.Ctx->getCurrentDwarfLoc();
709709
BC.Ctx->clearDwarfLocSeen();
710-
auto &MapLineEntries = BC.getDwarfLineTable(TargetUnitIndex)
711-
.getMCLineSections()
712-
.getMCLineEntries();
710+
const MCLineSection::MCLineDivisionMap &MapLineEntries =
711+
BC.getDwarfLineTable(TargetUnitIndex)
712+
.getMCLineSections()
713+
.getMCLineEntries();
713714
const auto *It = MapLineEntries.find(Streamer.getCurrentSectionOnly());
714-
auto NewLineEntry = MCDwarfLineEntry(&InstrLabel, DwarfLoc);
715+
MCDwarfLineEntry NewLineEntry = MCDwarfLineEntry(&InstrLabel, DwarfLoc);
715716

716-
// Check if line table exists and has entries before doing comparison
717+
// Check if line table exists and has entries before doing comparison.
717718
if (It != MapLineEntries.end() && !It->second.empty()) {
718719
// Check if the new line entry has the same debug info as the last one
719720
// to avoid duplicates. We don't compare labels since different
@@ -769,12 +770,11 @@ SMLoc BinaryEmitter::emitLineInfo(const BinaryFunction &BF, SMLoc NewLoc,
769770

770771
void BinaryEmitter::emitLineInfoEnd(const BinaryFunction &BF,
771772
MCSymbol *FunctionEndLabel,
772-
DWARFUnit *Unit) {
773-
assert(Unit && "DWARF unit expected");
773+
const DWARFUnit &Unit) {
774774
BC.Ctx->setCurrentDwarfLoc(0, 0, 0, DWARF2_FLAG_END_SEQUENCE, 0, 0);
775775
const MCDwarfLoc &DwarfLoc = BC.Ctx->getCurrentDwarfLoc();
776776
BC.Ctx->clearDwarfLocSeen();
777-
BC.getDwarfLineTable(Unit->getOffset())
777+
BC.getDwarfLineTable(Unit.getOffset())
778778
.getMCLineSections()
779779
.addLineEntry(MCDwarfLineEntry(FunctionEndLabel, DwarfLoc),
780780
Streamer.getCurrentSectionOnly());
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
SECTIONS {
2-
. = 0x400000 + SIZEOF_HEADERS;
2+
. = SIZEOF_HEADERS;
33
.interp : { *(.interp) }
44
.note.gnu.build-id : { *(.note.gnu.build-id) }
5+
. = 0x212e8;
56
.dynsym : { *(.dynsym) }
6-
. = 0x801000;
7+
. = 0x31860;
78
.text : { *(.text*) }
8-
. = 0x803000;
9+
. = 0x41c20;
910
.fini_array : { *(.fini_array) }
10-
. = 0x805000;
11+
. = 0x54e18;
1112
.data : { *(.data) }
12-
}
13+
}

0 commit comments

Comments
 (0)