DebugInfo: Simplify RangeSpan to be a plain struct

This is an effort to make RangeSpan and DebugLocStream::Entry more
similar to share code for their emission (to reuse the more complicated
code for using (& choosing when to use) base address selection entries,
etc).

It didn't seem like this struct was worth the complexity of
encapsulation - when the members could be initialized by the ctor to any
value (no validation) and the type is assignable (so there's no
mutability or other constraint being implemented by its interface).

llvm-svn: 373533
This commit is contained in:
David Blaikie 2019-10-02 22:27:24 +00:00
parent 4d39410b1e
commit b677cb8dc7
3 changed files with 15 additions and 21 deletions

View File

@ -326,13 +326,13 @@ void DwarfCompileUnit::addRange(RangeSpan Range) {
// emitted into and the subprogram was contained within. If these are the
// same then extend our current range, otherwise add this as a new range.
if (CURanges.empty() || !SameAsPrevCU ||
(&CURanges.back().getEnd()->getSection() !=
&Range.getEnd()->getSection())) {
(&CURanges.back().End->getSection() !=
&Range.End->getSection())) {
CURanges.push_back(Range);
return;
}
CURanges.back().setEnd(Range.getEnd());
CURanges.back().End = Range.End;
}
void DwarfCompileUnit::initStmtList() {
@ -506,7 +506,7 @@ void DwarfCompileUnit::attachRangesOrLowHighPC(
if (Ranges.size() == 1 || !DD->useRangesSection()) {
const RangeSpan &Front = Ranges.front();
const RangeSpan &Back = Ranges.back();
attachLowHighPC(Die, Front.getStart(), Back.getEnd());
attachLowHighPC(Die, Front.Begin, Back.End);
} else
addScopeRangeList(Die, std::move(Ranges));
}
@ -516,8 +516,8 @@ void DwarfCompileUnit::attachRangesOrLowHighPC(
SmallVector<RangeSpan, 2> List;
List.reserve(Ranges.size());
for (const InsnRange &R : Ranges)
List.push_back(RangeSpan(DD->getLabelBeforeInsn(R.first),
DD->getLabelAfterInsn(R.second)));
List.push_back(
{DD->getLabelBeforeInsn(R.first), DD->getLabelAfterInsn(R.second)});
attachRangesOrLowHighPC(Die, std::move(List));
}

View File

@ -1098,7 +1098,7 @@ void DwarfDebug::finalizeModuleInfo() {
// 2.17.3).
U.addUInt(U.getUnitDie(), dwarf::DW_AT_low_pc, dwarf::DW_FORM_addr, 0);
else
U.setBaseAddress(TheCU.getRanges().front().getStart());
U.setBaseAddress(TheCU.getRanges().front().Begin);
U.attachRangesOrLowHighPC(U.getUnitDie(), TheCU.takeRanges());
}
@ -1807,7 +1807,7 @@ void DwarfDebug::endFunctionImpl(const MachineFunction *MF) {
collectEntityInfo(TheCU, SP, Processed);
// Add the range of this function to the list of ranges for the CU.
TheCU.addRange(RangeSpan(Asm->getFunctionBegin(), Asm->getFunctionEnd()));
TheCU.addRange({Asm->getFunctionBegin(), Asm->getFunctionEnd()});
// Under -gmlt, skip building the subprogram if there are no inlined
// subroutines inside it. But with -fdebug-info-for-profiling, the subprogram
@ -2570,7 +2570,7 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
auto Size = Asm->MAI->getCodePointerSize();
for (const RangeSpan &Range : List.getRanges())
SectionRanges[&Range.getStart()->getSection()].push_back(&Range);
SectionRanges[&Range.Begin->getSection()].push_back(&Range);
const DwarfCompileUnit &CU = List.getCU();
const MCSymbol *CUBase = CU.getBaseAddress();
@ -2586,7 +2586,7 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
if (!Base && (P.second.size() > 1 || DwarfVersion < 5) &&
(CU.getCUNode()->getRangesBaseAddress() || DwarfVersion >= 5)) {
BaseIsSet = true;
Base = DD.getSectionLabel(&P.second.front()->getStart()->getSection());
Base = DD.getSectionLabel(&P.second.front()->Begin->getSection());
if (DwarfVersion >= 5) {
Asm->OutStreamer->AddComment("DW_RLE_base_addressx");
Asm->OutStreamer->EmitIntValue(dwarf::DW_RLE_base_addressx, 1);
@ -2605,8 +2605,8 @@ static void emitRangeList(DwarfDebug &DD, AsmPrinter *Asm,
}
for (const auto *RS : P.second) {
const MCSymbol *Begin = RS->getStart();
const MCSymbol *End = RS->getEnd();
const MCSymbol *Begin = RS->Begin;
const MCSymbol *End = RS->End;
assert(Begin && "Range without a begin symbol?");
assert(End && "Range without an end symbol?");
if (Base) {

View File

@ -32,15 +32,9 @@ class LexicalScope;
class MCSection;
// Data structure to hold a range for range lists.
class RangeSpan {
public:
RangeSpan(MCSymbol *S, MCSymbol *E) : Start(S), End(E) {}
const MCSymbol *getStart() const { return Start; }
const MCSymbol *getEnd() const { return End; }
void setEnd(const MCSymbol *E) { End = E; }
private:
const MCSymbol *Start, *End;
struct RangeSpan {
const MCSymbol *Begin;
const MCSymbol *End;
};
class RangeSpanList {