Skip to content

[NFC] Remove DIEVisitor constructor and move AbbrevCache population #7911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 13 additions & 24 deletions llvm/lib/MCCAS/MCCASObjectV1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3119,27 +3119,6 @@ struct DIEVisitor {
SmallVector<AbbrevContent> AbbrevContents;
};

DIEVisitor() = delete;

DIEVisitor(ArrayRef<StringRef> AbbrevEntries,
BinaryStreamReader DistinctReader, StringRef DistinctData,
std::function<void(StringRef)> HeaderCallback,
std::function<void(dwarf::Tag, uint64_t)> StartTagCallback,
std::function<void(dwarf::Attribute, dwarf::Form, StringRef, bool)>
AttrCallback,
std::function<void(bool)> EndTagCallback,
std::function<void(StringRef)> NewBlockCallback)
: AbbrevEntries(AbbrevEntries), DistinctReader(DistinctReader),
DistinctData(DistinctData), HeaderCallback(HeaderCallback),
StartTagCallback(StartTagCallback), AttrCallback(AttrCallback),
EndTagCallback(EndTagCallback), NewBlockCallback(NewBlockCallback) {
AbbrevEntryCache.reserve(AbbrevEntries.size());
for (unsigned I = 0; I < AbbrevEntries.size(); I++) {
if (Error E = materializeAbbrevDIE(encodeAbbrevIndex(I)))
report_fatal_error(std::move(E));
}
}

Error visitDIERef(DIEDedupeTopLevelRef Ref);
Error visitDIERef(ArrayRef<DIEDataRef> &DIEChildrenStack);
Error visitDIEAttrs(BinaryStreamReader &DataReader, StringRef DIEData,
Expand Down Expand Up @@ -3324,6 +3303,10 @@ static void popStack(BinaryStreamReader &Reader, StringRef &Data,
// Visit DIERef CAS objects and materialize them.
Error DIEVisitor::visitDIERef(ArrayRef<DIEDataRef> &DIEChildrenStack) {

for (unsigned I = 0; I < AbbrevEntries.size(); I++)
if (Error E = materializeAbbrevDIE(encodeAbbrevIndex(I)))
return E;

std::stack<std::pair<StringRef, unsigned>> StackOfNodes;
auto Data = DIEChildrenStack.empty() ? StringRef()
: DIEChildrenStack.front().getData();
Expand Down Expand Up @@ -3451,8 +3434,14 @@ Error mccasformats::v1::visitDebugInfo(
HeaderCallback(toStringRef(HeaderData));

append_range(TotAbbrevEntries, LoadedTopRef->AbbrevEntries);
DIEVisitor Visitor{TotAbbrevEntries, DistinctReader, UncompressedDistinctData,
HeaderCallback, StartTagCallback, AttrCallback,
EndTagCallback, NewBlockCallback};
DIEVisitor Visitor{{},
TotAbbrevEntries,
DistinctReader,
UncompressedDistinctData,
HeaderCallback,
StartTagCallback,
AttrCallback,
EndTagCallback,
NewBlockCallback};
return Visitor.visitDIERef(LoadedTopRef->RootDIE);
}