[llvm] [BOLT][DWARF][NFC] Move common access outside of parallel function (PR #99728)
Sayhaan Siddiqui via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 23 14:20:43 PDT 2024
https://github.com/sayhaan updated https://github.com/llvm/llvm-project/pull/99728
>From 0c66a79e4c1a95e7f612bc448c64d5493e6c3b5f Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Fri, 19 Jul 2024 17:59:20 -0700
Subject: [PATCH 1/3] Move common access outside of parallel function
Summary:
Test Plan:
Reviewers:
Subscribers:
Tasks:
Tags:
Differential Revision: https://phabricator.intern.facebook.com/D59997905
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
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);
>From 9baebd45cc649dda87636f15a8aa6f19cd6b80d6 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 23 Jul 2024 14:15:35 -0700
Subject: [PATCH 2/3] Updates
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 66520ebab47e1..1ae1aef56eb24 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -669,8 +669,8 @@ void DWARFRewriter::updateDebugInfo() {
DIEBuilder &DIEBlder,
DebugRangesSectionWriter &TempRangesSectionWriter,
DebugAddrWriter &AddressWriter,
- std::string &DWOName,
- std::optional<std::string> &DwarfOutputPath) {
+ const std::string &DWOName,
+ const std::optional<std::string> &DwarfOutputPath) {
DIEBuilder DWODIEBuilder(BC, &(SplitCU).getContext(), DebugNamesTable,
&Unit);
DWODIEBuilder.buildDWOUnit(SplitCU);
@@ -751,13 +751,11 @@ 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,
+ std::string DWOName = DIEBlder.updateDWONameCompDir(*StrOffstsWriter, *StrWriter, *CU,
DwarfOutputPath, std::nullopt);
processSplitCU(*CU, **SplitCU, DIEBlder, *TempRangesSectionWriter,
AddressWriter, DWOName, DwarfOutputPath);
>From 3297c67c2ffd2d1274734c6218b2282c6f0d6246 Mon Sep 17 00:00:00 2001
From: Sayhaan Siddiqui <sayhaan at meta.com>
Date: Tue, 23 Jul 2024 14:20:28 -0700
Subject: [PATCH 3/3] Formatting changes
---
bolt/lib/Rewrite/DWARFRewriter.cpp | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp
index 1ae1aef56eb24..674b5f17adb3f 100644
--- a/bolt/lib/Rewrite/DWARFRewriter.cpp
+++ b/bolt/lib/Rewrite/DWARFRewriter.cpp
@@ -755,8 +755,8 @@ void DWARFRewriter::updateDebugInfo() {
opts::DwarfOutputPath.empty()
? std::nullopt
: std::optional<std::string>(opts::DwarfOutputPath.c_str());
- std::string DWOName = DIEBlder.updateDWONameCompDir(*StrOffstsWriter, *StrWriter, *CU,
- DwarfOutputPath, std::nullopt);
+ std::string DWOName = DIEBlder.updateDWONameCompDir(
+ *StrOffstsWriter, *StrWriter, *CU, DwarfOutputPath, std::nullopt);
processSplitCU(*CU, **SplitCU, DIEBlder, *TempRangesSectionWriter,
AddressWriter, DWOName, DwarfOutputPath);
}
More information about the llvm-commits
mailing list