Skip to content

Commit 9a4d5fa

Browse files
committed
Address Comments....
1 parent 23d83a7 commit 9a4d5fa

File tree

5 files changed

+39
-42
lines changed

5 files changed

+39
-42
lines changed

bolt/lib/Core/BinaryFunction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ static SMLoc findDebugLineInformationForInstructionAt(
194194

195195
SMLoc NullResult = DebugLineTableRowRef::NULL_ROW.toSMLoc();
196196
uint32_t RowIndex = LineTable->lookupAddress(
197-
{Address, object::SectionedAddress::UndefSection}, false);
197+
{Address, object::SectionedAddress::UndefSection});
198198
if (RowIndex == LineTable->UnknownRowIndex)
199199
return NullResult;
200200

llvm/include/llvm/DebugInfo/DIContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ struct DILineInfo {
5151
// DWARF-specific.
5252
uint32_t Discriminator = 0;
5353

54-
bool IsApproximatedLine = false;
54+
bool IsApproximateLine = false;
5555
DILineInfo()
5656
: FileName(BadString), FunctionName(BadString), StartFileName(BadString) {
5757
}

llvm/include/llvm/DebugInfo/DWARF/DWARFDebugLine.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ class DWARFDebugLine {
240240

241241
/// Returns the index of the row with file/line info for a given address,
242242
/// or UnknownRowIndex if there is no such row.
243-
uint32_t lookupAddress(object::SectionedAddress Address, bool Approximate,
243+
uint32_t lookupAddress(object::SectionedAddress Address,
244244
bool *IsApproximateLine = nullptr) const;
245245

246246
bool lookupAddressRange(object::SectionedAddress Address, uint64_t Size,
@@ -303,7 +303,6 @@ class DWARFDebugLine {
303303
DILineInfoSpecifier::FileLineInfoKind Kind) const;
304304

305305
uint32_t lookupAddressImpl(object::SectionedAddress Address,
306-
bool Approximate,
307306
bool *IsApproximateLine = nullptr) const;
308307

309308
bool lookupAddressRangeImpl(object::SectionedAddress Address, uint64_t Size,

llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -158,13 +158,12 @@ void DWARFDebugLine::Prologue::dump(raw_ostream &OS,
158158
uint32_t FileBase = getVersion() >= 5 ? 0 : 1;
159159
for (uint32_t I = 0; I != FileNames.size(); ++I) {
160160
const FileNameEntry &FileEntry = FileNames[I];
161-
OS << format("file_names[%3u]:\n", I + FileBase);
162-
OS << " name: ";
161+
OS << format("file_names[%3u]:\n", I + FileBase);
162+
OS << " name: ";
163163
FileEntry.Name.dump(OS, DumpOptions);
164-
OS << '\n'
165-
<< format(" dir_index: %" PRIu64 "\n", FileEntry.DirIdx);
164+
OS << '\n' << format(" dir_index: %" PRIu64 "\n", FileEntry.DirIdx);
166165
if (ContentTypes.HasMD5)
167-
OS << " md5_checksum: " << FileEntry.Checksum.digest() << '\n';
166+
OS << " md5_checksum: " << FileEntry.Checksum.digest() << '\n';
168167
if (ContentTypes.HasModTime)
169168
OS << format(" mod_time: 0x%8.8" PRIx64 "\n", FileEntry.ModTime);
170169
if (ContentTypes.HasLength)
@@ -604,9 +603,10 @@ Expected<const DWARFDebugLine::LineTable *> DWARFDebugLine::getOrParseLineTable(
604603
DWARFDataExtractor &DebugLineData, uint64_t Offset, const DWARFContext &Ctx,
605604
const DWARFUnit *U, function_ref<void(Error)> RecoverableErrorHandler) {
606605
if (!DebugLineData.isValidOffset(Offset))
607-
return createStringError(errc::invalid_argument, "offset 0x%8.8" PRIx64
608-
" is not a valid debug line section offset",
609-
Offset);
606+
return createStringError(errc::invalid_argument,
607+
"offset 0x%8.8" PRIx64
608+
" is not a valid debug line section offset",
609+
Offset);
610610

611611
std::pair<LineTableIter, bool> Pos =
612612
LineTableMap.insert(LineTableMapTy::value_type(Offset, LineTable()));
@@ -966,7 +966,8 @@ Error DWARFDebugLine::LineTable::parse(
966966

967967
if (Cursor && Verbose) {
968968
*OS << " (";
969-
DWARFFormValue::dumpAddress(*OS, OpcodeAddressSize, State.Row.Address.Address);
969+
DWARFFormValue::dumpAddress(*OS, OpcodeAddressSize,
970+
State.Row.Address.Address);
970971
*OS << ')';
971972
}
972973
}
@@ -1159,8 +1160,7 @@ Error DWARFDebugLine::LineTable::parse(
11591160
// DW_LNS_advance_pc. Such assemblers, however, can use
11601161
// DW_LNS_fixed_advance_pc instead, sacrificing compression.
11611162
{
1162-
uint16_t PCOffset =
1163-
TableData.getRelocatedValue(Cursor, 2);
1163+
uint16_t PCOffset = TableData.getRelocatedValue(Cursor, 2);
11641164
if (Cursor) {
11651165
State.Row.Address.Address += PCOffset;
11661166
State.Row.OpIndex = 0;
@@ -1314,24 +1314,22 @@ uint32_t DWARFDebugLine::LineTable::findRowInSeq(
13141314

13151315
uint32_t
13161316
DWARFDebugLine::LineTable::lookupAddress(object::SectionedAddress Address,
1317-
bool Approximate,
13181317
bool *IsApproximateLine) const {
13191318

13201319
// Search for relocatable addresses
1321-
uint32_t Result = lookupAddressImpl(Address, Approximate, IsApproximateLine);
1320+
uint32_t Result = lookupAddressImpl(Address, IsApproximateLine);
13221321

13231322
if (Result != UnknownRowIndex ||
13241323
Address.SectionIndex == object::SectionedAddress::UndefSection)
13251324
return Result;
13261325

13271326
// Search for absolute addresses
13281327
Address.SectionIndex = object::SectionedAddress::UndefSection;
1329-
return lookupAddressImpl(Address, Approximate, IsApproximateLine);
1328+
return lookupAddressImpl(Address, IsApproximateLine);
13301329
}
13311330

13321331
uint32_t
13331332
DWARFDebugLine::LineTable::lookupAddressImpl(object::SectionedAddress Address,
1334-
bool Approximate,
13351333
bool *IsApproximateLine) const {
13361334
// First, find an instruction sequence containing the given address.
13371335
DWARFDebugLine::Sequence Sequence;
@@ -1343,21 +1341,21 @@ DWARFDebugLine::LineTable::lookupAddressImpl(object::SectionedAddress Address,
13431341
return UnknownRowIndex;
13441342

13451343
uint32_t RowIndex = findRowInSeq(*It, Address);
1346-
if (RowIndex == UnknownRowIndex || !Approximate)
1344+
if (RowIndex == UnknownRowIndex || IsApproximateLine == nullptr)
13471345
return RowIndex;
13481346

13491347
// Approximation will only be attempted if a valid RowIndex exists.
1350-
if (Approximate) {
1351-
// Approximation Loop
1352-
for (uint32_t ApproxRowIndex = RowIndex;
1353-
ApproxRowIndex >= It->FirstRowIndex; --ApproxRowIndex) {
1354-
if (Rows[ApproxRowIndex].Line)
1355-
return ApproxRowIndex;
1356-
*IsApproximateLine = true;
1357-
}
1358-
// Approximation Loop fails to find the valid ApproxRowIndex
1359-
*IsApproximateLine = false;
1348+
uint32_t ApproxRowIndex = RowIndex;
1349+
// Approximation Loop
1350+
for (; ApproxRowIndex >= It->FirstRowIndex; --ApproxRowIndex) {
1351+
if (Rows[ApproxRowIndex].Line)
1352+
return ApproxRowIndex;
1353+
*IsApproximateLine = true;
13601354
}
1355+
// Approximation Loop fails to find the valid ApproxRowIndex
1356+
if (ApproxRowIndex < It->FirstRowIndex)
1357+
*IsApproximateLine = false;
1358+
13611359
return RowIndex;
13621360
}
13631361

@@ -1501,9 +1499,8 @@ bool DWARFDebugLine::LineTable::getFileLineInfoForAddress(
15011499
object::SectionedAddress Address, bool Approximate, const char *CompDir,
15021500
FileLineInfoKind Kind, DILineInfo &Result) const {
15031501
// Get the index of row we're looking for in the line table.
1504-
15051502
uint32_t RowIndex =
1506-
lookupAddress(Address, Approximate, &Result.IsApproximatedLine);
1503+
lookupAddress(Address, Approximate ? &Result.IsApproximateLine : nullptr);
15071504
if (RowIndex == -1U)
15081505
return false;
15091506
// Take file number and line/column from the row.

llvm/lib/DebugInfo/Symbolize/DIPrinter.cpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,19 @@ void PlainPrinterBase::printFunctionName(StringRef FunctionName, bool Inlined) {
131131

132132
void LLVMPrinter::printSimpleLocation(StringRef Filename,
133133
const DILineInfo &Info) {
134-
OS << Filename << ':' << Info.Line << ':' << Info.Column
135-
<< (Info.IsApproximatedLine ? (" " + Twine(Info.ApproxString)) : "")
136-
<< '\n';
134+
OS << Filename << ':' << Info.Line << ':' << Info.Column;
135+
if (Info.IsApproximateLine)
136+
OS << " " << Info.ApproxString;
137+
OS << "\n";
137138
printContext(
138139
SourceCode(Filename, Info.Line, Config.SourceContextLines, Info.Source));
139140
}
140141

141142
void GNUPrinter::printSimpleLocation(StringRef Filename,
142143
const DILineInfo &Info) {
143-
OS << Filename << ':' << Info.Line
144-
<< (Info.IsApproximatedLine ? (" " + Twine(Info.ApproxString)) : "");
144+
OS << Filename << ':' << Info.Line;
145+
if (Info.IsApproximateLine)
146+
OS << " " << Info.ApproxString;
145147
if (Info.Discriminator)
146148
OS << " (discriminator " << Info.Discriminator << ')';
147149
OS << '\n';
@@ -161,9 +163,8 @@ void PlainPrinterBase::printVerbose(StringRef Filename,
161163
OS << " Column: " << Info.Column << '\n';
162164
if (Info.Discriminator)
163165
OS << " Discriminator: " << Info.Discriminator << '\n';
164-
if (Info.IsApproximatedLine)
165-
OS << " Approximate: "
166-
<< "true" << '\n';
166+
if (Info.IsApproximateLine)
167+
OS << " Approximate: true" << '\n';
167168
}
168169

169170
void LLVMPrinter::printStartAddress(const DILineInfo &Info) {
@@ -315,8 +316,8 @@ static json::Object toJSON(const DILineInfo &LineInfo) {
315316
{"Line", LineInfo.Line},
316317
{"Column", LineInfo.Column},
317318
{"Discriminator", LineInfo.Discriminator}});
318-
if (LineInfo.IsApproximatedLine)
319-
Obj.insert({"Approximate", LineInfo.IsApproximatedLine});
319+
if (LineInfo.IsApproximateLine)
320+
Obj.insert({"Approximate", LineInfo.IsApproximateLine});
320321
return Obj;
321322
}
322323

0 commit comments

Comments
 (0)