[llvm] Make DWARFUnitVector threadsafe. (PR #71487)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 6 21:27:29 PST 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 407afbf1bc276fb70569da335e5ef57b7cb119db 4078836a3bc4508deb4e0a3615f565ae23ab5dcd -- llvm/include/llvm/DebugInfo/DWARF/DWARFContext.h llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h llvm/lib/DebugInfo/DWARF/DWARFContext.cpp llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp llvm/tools/llvm-dwarfutil/DebugInfoLinker.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
index 55ffd6118865..f74c8e5d36bc 100644
--- a/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
+++ b/llvm/include/llvm/DebugInfo/DWARF/DWARFUnit.h
@@ -123,13 +123,15 @@ bool isCompileUnit(const std::unique_ptr<DWARFUnit> &U);
/// Describe a collection of units. Intended to hold all units either from
/// .debug_info and .debug_types, or from .debug_info.dwo and .debug_types.dwo.
-class DWARFUnitVector final : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
+class DWARFUnitVector final
+ : public SmallVector<std::unique_ptr<DWARFUnit>, 1> {
int NumInfoUnits = -1;
public:
using UnitVector = SmallVectorImpl<std::unique_ptr<DWARFUnit>>;
using iterator = typename UnitVector::const_iterator;
- using iterator_range = llvm::iterator_range<typename UnitVector::const_iterator>;
+ using iterator_range =
+ llvm::iterator_range<typename UnitVector::const_iterator>;
using compile_unit_range =
decltype(make_filter_range(std::declval<iterator_range>(), isCompileUnit));
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index d20ad804f05b..c235cd5210f2 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -44,19 +44,20 @@ void DWARFUnitVector::addUnitsForSection(DWARFContext &C,
DWARFSectionKind SectionKind) {
const DWARFObject &D = C.getDWARFObj();
addUnitsImpl(C, D, Section, C.getDebugAbbrev(), &D.getRangesSection(),
- &D.getLocSection(), D.getStrSection(),
- D.getStrOffsetsSection(), &D.getAddrSection(),
- D.getLineSection(), D.isLittleEndian(), false, SectionKind);
+ &D.getLocSection(), D.getStrSection(), D.getStrOffsetsSection(),
+ &D.getAddrSection(), D.getLineSection(), D.isLittleEndian(),
+ false, SectionKind);
}
void DWARFUnitVector::addUnitsForDWOSection(DWARFContext &C,
const DWARFSection &DWOSection,
DWARFSectionKind SectionKind) {
const DWARFObject &D = C.getDWARFObj();
- addUnitsImpl(C, D, DWOSection, C.getDebugAbbrevDWO(), &D.getRangesDWOSection(),
- &D.getLocDWOSection(), D.getStrDWOSection(),
- D.getStrOffsetsDWOSection(), &D.getAddrSection(),
- D.getLineDWOSection(), C.isLittleEndian(), true, SectionKind);
+ addUnitsImpl(C, D, DWOSection, C.getDebugAbbrevDWO(),
+ &D.getRangesDWOSection(), &D.getLocDWOSection(),
+ D.getStrDWOSection(), D.getStrOffsetsDWOSection(),
+ &D.getAddrSection(), D.getLineDWOSection(), C.isLittleEndian(),
+ true, SectionKind);
}
void DWARFUnitVector::addUnitsImpl(
@@ -70,7 +71,7 @@ void DWARFUnitVector::addUnitsImpl(
&LS](uint64_t Offset, DWARFSectionKind SectionKind,
const DWARFSection *CurSection,
const DWARFUnitIndex::Entry *IndexEntry)
- -> std::unique_ptr<DWARFUnit> {
+ -> std::unique_ptr<DWARFUnit> {
const DWARFSection &InfoSection = CurSection ? *CurSection : Section;
DWARFDataExtractor Data(Obj, InfoSection, LE, 0);
if (!Data.isValidOffset(Offset))
@@ -97,13 +98,13 @@ void DWARFUnitVector::addUnitsImpl(
return nullptr;
std::unique_ptr<DWARFUnit> U;
if (Header.isTypeUnit())
- U = std::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA,
- RS, LocSection, SS, SOS, AOS, LS,
- LE, IsDWO, *this);
+ U = std::make_unique<DWARFTypeUnit>(Context, InfoSection, Header, DA, RS,
+ LocSection, SS, SOS, AOS, LS, LE,
+ IsDWO, *this);
else
- U = std::make_unique<DWARFCompileUnit>(Context, InfoSection, Header,
- DA, RS, LocSection, SS, SOS,
- AOS, LS, LE, IsDWO, *this);
+ U = std::make_unique<DWARFCompileUnit>(Context, InfoSection, Header, DA,
+ RS, LocSection, SS, SOS, AOS, LS,
+ LE, IsDWO, *this);
return U;
};
// Find a reasonable insertion point within the vector. We skip over
``````````
</details>
https://github.com/llvm/llvm-project/pull/71487
More information about the llvm-commits
mailing list