-
Notifications
You must be signed in to change notification settings - Fork 341
Re-architect MCCAS debug info section materialization to no longer be recursive or attach children DIEDataRefs to their parents #7811
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
Re-architect MCCAS debug info section materialization to no longer be recursive or attach children DIEDataRefs to their parents #7811
Conversation
87092f0
to
2e3b17b
Compare
2e3b17b
to
02c21fb
Compare
2158b92
to
cbea924
Compare
cbea924
to
22446ec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I still think we would benefit a lot from a simpler while loop, and I spent some time trying to figure out if this is feasiable. As you know better than I do, the devil is in the details, so I tried to be pretty thoughtful here. If you don't think this is possibe, that's fine, but what do you think of this algorithm?
(btw, you are right about the need to push the "data" into the stack as well as the reader, the visitDIEAttrs
need to "peek" into the data, and the stream class doesn't give us access to it)
// DIEData == ArrayRef<StringRef>
BinaryStreamReader Reader(DIEData[0], /*offset*/ 0);
stack.push({Reader, DIEData[0]});
DIEData = DIEData.drop_front();
while(!stack.empty() {
auto AbbrevIdx = DistinctReader.read_abbrev();
if (AbbrevIdx == getDIEInAnotherBlockMarker()) {
NewBlockCallback (...)
BinaryStreamReader Reader(DIEData[0], /*offset*/ 0);
stack.push(Reader, DIEData[0]);
DIEData = DIEData.drop_front();
continue;
}
auto CurrentReader, CurrentData = stack.pop_back_val();
if (AbbrevIdx == getEndOfDIESiblingsMarker())
EndTagCallback(true /*had children*/);
else {
AbbrevReader = get abbrev reader for AbbrevIdx;
Tag = AbbrevReader.readTag();
StartTagCallback(*MaybeTag, AbbrevIdx);
visitDIEAttrs(AbbrevReader, CurrentReader, CurrentData))
if (!AbbrevReader.HasChildren)
EndTagCallback(false /*had children*/);
}
// Reached the end of a DIE, if this reader still has data in it, push it.
if (!CurrentReader.empty())
stack.push({CurrentReader, CurrentData});
}
22446ec
to
eb67eed
Compare
eb67eed
to
a8fb603
Compare
DIEDedupeTopLevelRef is a CAS block that holds no data and has references to DIEDataRef CAS blocks. This makes it easy to check that a DIETopLevelRef in a CAS is valid, as it should only have 3 references to it, a DIEDedupeTopLevelRef, a DIEAbbrevSetRef, and a DIEDistinctDataRef
With this change, the layout of the debug info section in MCCAS has been changed. Now, if there is a DIE that can be split off into it's own CAS block, we do not attach it to its parent CAS block as a reference, it gets added as a neighbor instead. This reduces the dependencies between CAS blocks and increases chances of deduplication if a DIEDataRef doesn't dedupe, by making sure it's parent will still dedupe. This change also re-writes the materialization of the debug info section to be iterative, rather than recursive.
a8fb603
to
d91e87e
Compare
@swift-ci please test |
@swift-ci please test llvm |
1 similar comment
@swift-ci please test llvm |
Ok thank you I go to home GitHub |
Cherry-pick PR #7811 to stable/20230725
With this change, the layout of the debug info section in MCCAS has been changed. Now, if there is a DIE that can be split off into it's own CAS block, we do not attach it to its parent CAS block as a reference, it gets added as a neighbor instead. This reduces the dependencies between CAS blocks and increases chances of deduplication if a DIEDataRef doesn't dedupe, by making sure it's parent will still dedupe.
This change also re-writes the materialization of the debug info section to be iterative, rather than recursive.
It also introduces the new cas block
DIEDedupeTopLevelRef
The results of this work give us a cleaner instruments trace which enabled us to identify the function
visitDIEAttrs
as a place we could optimize MCCAS replay