[llvm] Reduce llvm-gsymutil memory usage (PR #139907)
via llvm-commits
llvm-commits at lists.llvm.org
Thu May 15 14:10:52 PDT 2025
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 HEAD~1 HEAD --extensions cpp,h -- 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/lib/DebugInfo/GSYM/DwarfTransformer.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
index 8aad787ec..1d2f379d1 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
@@ -622,7 +622,9 @@ public:
return getNormalTypeUnitMap();
}
- Error doWorkThreadSafely(function_ref<Error()> Work) override { return Work(); }
+ Error doWorkThreadSafely(function_ref<Error()> Work) override {
+ return Work();
+ }
};
class ThreadSafeState : public ThreadUnsafeDWARFContextState {
diff --git a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
index ce12a5a5f..e351b12fb 100644
--- a/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
+++ b/llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
@@ -497,19 +497,21 @@ void DWARFUnit::extractDIEsIfNeeded(bool CUDieOnly) {
Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
return Context.doWorkThreadSafely([&]() -> Error {
- if ((CUDieOnly && !DieArray.empty()) ||
- DieArray.size() > 1)
- return Error::success();; // Already parsed.
+ if ((CUDieOnly && !DieArray.empty()) || DieArray.size() > 1)
+ return Error::success();
+ ; // Already parsed.
bool HasCUDie = !DieArray.empty();
extractDIEsToVector(!HasCUDie, !CUDieOnly, DieArray);
if (DieArray.empty())
- return Error::success();;
+ return Error::success();
+ ;
// If CU DIE was just parsed, copy several attribute values from it.
if (HasCUDie)
- return Error::success();;
+ return Error::success();
+ ;
DWARFDie UnitDie(this, &DieArray[0]);
if (std::optional<uint64_t> DWOId =
@@ -542,9 +544,9 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
: determineStringOffsetsTableContribution(DA);
if (!StringOffsetOrError) {
return createStringError(errc::invalid_argument,
- "invalid reference to or invalid content in "
- ".debug_str_offsets[.dwo]: " +
- toString(StringOffsetOrError.takeError()));
+ "invalid reference to or invalid content in "
+ ".debug_str_offsets[.dwo]: " +
+ toString(StringOffsetOrError.takeError()));
}
StringOffsetsTableContribution = *StringOffsetOrError;
@@ -565,17 +567,17 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
DWARFListTableHeader::getHeaderSize(Header.getFormat()));
} else
setRangesSection(&Context.getDWARFObj().getRnglistsSection(),
- toSectionOffset(UnitDie.find(DW_AT_rnglists_base),
- DWARFListTableHeader::getHeaderSize(
- Header.getFormat())));
+ toSectionOffset(UnitDie.find(DW_AT_rnglists_base),
+ DWARFListTableHeader::getHeaderSize(
+ Header.getFormat())));
}
if (IsDWO) {
// If we are reading a package file, we need to adjust the location list
// data based on the index entries.
StringRef Data = Header.getVersion() >= 5
- ? Context.getDWARFObj().getLoclistsDWOSection().Data
- : Context.getDWARFObj().getLocDWOSection().Data;
+ ? Context.getDWARFObj().getLoclistsDWOSection().Data
+ : Context.getDWARFObj().getLocDWOSection().Data;
if (auto *IndexEntry = Header.getIndexEntry())
if (const auto *C = IndexEntry->getContribution(
Header.getVersion() >= 5 ? DW_SECT_LOCLISTS : DW_SECT_EXT_LOC))
@@ -588,8 +590,8 @@ Error DWARFUnit::tryExtractDIEsIfNeeded(bool CUDieOnly) {
} else if (getVersion() >= 5) {
LocTable = std::make_unique<DWARFDebugLoclists>(
DWARFDataExtractor(Context.getDWARFObj(),
- Context.getDWARFObj().getLoclistsSection(),
- IsLittleEndian, getAddressByteSize()),
+ Context.getDWARFObj().getLoclistsSection(),
+ IsLittleEndian, getAddressByteSize()),
getVersion());
} else {
LocTable = std::make_unique<DWARFDebugLoc>(DWARFDataExtractor(
@@ -662,13 +664,13 @@ void DWARFUnit::clearDIEs(bool KeepCUDie, bool KeepDWODies) {
DWO->clearDIEs(KeepCUDie, KeepDWODies);
}
// Do not use resize() + shrink_to_fit() to free memory occupied by dies.
- // shrink_to_fit() is a *non-binding* request to reduce capacity() to size().
- // It depends on the implementation whether the request is fulfilled.
- // Create a new vector with a small capacity and assign it to the DieArray to
- // have previous contents freed.
+ // shrink_to_fit() is a *non-binding* request to reduce capacity() to
+ // size(). It depends on the implementation whether the request is
+ // fulfilled. Create a new vector with a small capacity and assign it to the
+ // DieArray to have previous contents freed.
DieArray = (KeepCUDie && !DieArray.empty())
- ? std::vector<DWARFDebugInfoEntry>({DieArray[0]})
- : std::vector<DWARFDebugInfoEntry>();
+ ? std::vector<DWARFDebugInfoEntry>({DieArray[0]})
+ : std::vector<DWARFDebugInfoEntry>();
return Error::success();
}));
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139907
More information about the llvm-commits
mailing list