-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BOLT][DWARF][NFC] Move initialization of DWOName outside of lambda #99728
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
Conversation
dfe7807
to
c9bac7e
Compare
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D59997905
c9bac7e
to
0c66a79
Compare
@llvm/pr-subscribers-bolt Author: Sayhaan Siddiqui (sayhaan) ChangesFollowup to the splitting of processUnitDIE, moves code that accesses common resource to be outside of the function that will be parallelized. Full diff: https://github.com/llvm/llvm-project/pull/99728.diff 1 Files Affected:
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index f0dd7baf82879..66520ebab47e1 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -668,20 +668,12 @@ void DWARFRewriter::updateDebugInfo() {
auto processSplitCU = [&](DWARFUnit &Unit, DWARFUnit &SplitCU,
DIEBuilder &DIEBlder,
DebugRangesSectionWriter &TempRangesSectionWriter,
- DebugAddrWriter &AddressWriter) {
+ DebugAddrWriter &AddressWriter,
+ std::string &DWOName,
+ std::optional<std::string> &DwarfOutputPath) {
DIEBuilder DWODIEBuilder(BC, &(SplitCU).getContext(), DebugNamesTable,
&Unit);
DWODIEBuilder.buildDWOUnit(SplitCU);
- std::string DWOName = "";
- std::optional<std::string> DwarfOutputPath =
- opts::DwarfOutputPath.empty()
- ? std::nullopt
- : std::optional<std::string>(opts::DwarfOutputPath.c_str());
- {
- std::lock_guard<std::mutex> Lock(AccessMutex);
- DWOName = DIEBlder.updateDWONameCompDir(
- *StrOffstsWriter, *StrWriter, Unit, DwarfOutputPath, std::nullopt);
- }
DebugStrOffsetsWriter DWOStrOffstsWriter(BC);
DebugStrWriter DWOStrWriter((SplitCU).getContext(), true);
DWODIEBuilder.updateDWONameCompDirForTypes(
@@ -759,8 +751,16 @@ void DWARFRewriter::updateDebugInfo() {
DebugRangesSectionWriter *TempRangesSectionWriter =
CU->getVersion() >= 5 ? RangeListsWritersByCU[*DWOId].get()
: LegacyRangesWritersByCU[*DWOId].get();
+ std::string DWOName = "";
+ std::optional<std::string> DwarfOutputPath =
+ opts::DwarfOutputPath.empty()
+ ? std::nullopt
+ : std::optional<std::string>(opts::DwarfOutputPath.c_str());
+ std::lock_guard<std::mutex> Lock(AccessMutex);
+ DWOName = DIEBlder.updateDWONameCompDir(*StrOffstsWriter, *StrWriter, *CU,
+ DwarfOutputPath, std::nullopt);
processSplitCU(*CU, **SplitCU, DIEBlder, *TempRangesSectionWriter,
- AddressWriter);
+ AddressWriter, DWOName, DwarfOutputPath);
}
for (DWARFUnit *CU : DIEBlder.getProcessedCUs())
processMainBinaryCU(*CU, DIEBlder);
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
opts::DwarfOutputPath.empty() | ||
? std::nullopt | ||
: std::optional<std::string>(opts::DwarfOutputPath.c_str()); | ||
std::string DWOName = DIEBlder.updateDWONameCompDir( |
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.
Why does hoisting this out of the lambda mean you don't need the lock anymore?
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.
The lock was previously part of the old multithreading implementation which we weren't using. Previously the plan was to remove it in a followup PR but since we're moving it out of the lambda here it doesn't make sense to have the lock at all since DWOName is processed sequentially.
NIt. Change title to be more clear what you moved. |
…99728) Summary: Followup to the splitting of processUnitDIE, moves code that accesses common resource to be outside of the function that will be parallelized. Followup to #99957 Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250695
Followup to the splitting of processUnitDIE, moves code that accesses common resource to be outside of the function that will be parallelized.
Followup to #99957