Skip to content

[DWARFLinker][NFC] Move common code into the base library: IndexedValuesMap. #77437

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

Merged
merged 2 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions llvm/include/llvm/DWARFLinker/Classic/DWARFLinker.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "llvm/CodeGen/NonRelocatableStringpool.h"
#include "llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h"
#include "llvm/DWARFLinker/DWARFLinkerBase.h"
#include "llvm/DWARFLinker/IndexedValuesMap.h"
#include "llvm/DebugInfo/DWARF/DWARFContext.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugLine.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugRangeList.h"
Expand All @@ -33,25 +34,7 @@ namespace classic {
class DeclContextTree;

using Offset2UnitMap = DenseMap<uint64_t, CompileUnit *>;

struct DebugDieValuePool {
DenseMap<uint64_t, uint64_t> DieValueMap;
SmallVector<uint64_t> DieValues;

uint64_t getValueIndex(uint64_t Value) {
DenseMap<uint64_t, uint64_t>::iterator It = DieValueMap.find(Value);
if (It == DieValueMap.end()) {
It = DieValueMap.insert(std::make_pair(Value, DieValues.size())).first;
DieValues.push_back(Value);
}
return It->second;
}

void clear() {
DieValueMap.clear();
DieValues.clear();
}
};
using DebugDieValuePool = IndexedValuesMap<uint64_t>;

/// DwarfEmitter presents interface to generate all debug info tables.
class DwarfEmitter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H
#define LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H
#ifndef LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
#define LLVM_DWARFLINKER_INDEXEDVALUESMAP_H

#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
Expand All @@ -16,8 +16,8 @@

namespace llvm {
namespace dwarf_linker {
namespace parallel {

/// This class stores values sequentually and assigns index to the each value.
template <typename T> class IndexedValuesMap {
public:
uint64_t getValueIndex(T Value) {
Expand All @@ -29,7 +29,7 @@ template <typename T> class IndexedValuesMap {
return It->second;
}

const SmallVector<T> &getValues() { return Values; }
const SmallVector<T> &getValues() const { return Values; }

void clear() {
ValueToIndexMap.clear();
Expand All @@ -44,8 +44,7 @@ template <typename T> class IndexedValuesMap {
SmallVector<T> Values;
};

} // end of namespace parallel
} // end of namespace dwarf_linker
} // end of namespace llvm

#endif // LLVM_LIB_DWARFLINKER_PARALLEL_INDEXEDVALUESMAP_H
#endif // LLVM_DWARFLINKER_INDEXEDVALUESMAP_H
6 changes: 3 additions & 3 deletions llvm/lib/DWARFLinker/Classic/DWARFLinker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2048,13 +2048,13 @@ void DWARFLinker::DIECloner::emitDebugAddrSection(
if (DwarfVersion < 5)
return;

if (AddrPool.DieValues.empty())
if (AddrPool.getValues().empty())
return;

MCSymbol *EndLabel = Emitter->emitDwarfDebugAddrsHeader(Unit);
patchAddrBase(*Unit.getOutputUnitDIE(),
DIEInteger(Emitter->getDebugAddrSectionSize()));
Emitter->emitDwarfDebugAddrs(AddrPool.DieValues,
Emitter->emitDwarfDebugAddrs(AddrPool.getValues(),
Unit.getOrigUnit().getAddressByteSize());
Emitter->emitDwarfDebugAddrsFooter(Unit, EndLabel);
}
Expand Down Expand Up @@ -2880,7 +2880,7 @@ Error DWARFLinker::link() {
if (TheDwarfEmitter != nullptr) {
TheDwarfEmitter->emitAbbrevs(Abbreviations, Options.TargetDWARFVersion);
TheDwarfEmitter->emitStrings(DebugStrPool);
TheDwarfEmitter->emitStringOffsets(StringOffsetPool.DieValues,
TheDwarfEmitter->emitStringOffsets(StringOffsetPool.getValues(),
Options.TargetDWARFVersion);
TheDwarfEmitter->emitLineStrings(DebugLineStrPool);
for (AccelTableKind TableKind : Options.AccelTables) {
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/DWARFLinker/Parallel/DWARFLinkerUnit.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERUNIT_H

#include "DWARFLinkerGlobalData.h"
#include "IndexedValuesMap.h"
#include "OutputSections.h"
#include "llvm/CodeGen/DIE.h"
#include "llvm/DWARFLinker/IndexedValuesMap.h"
#include "llvm/DWARFLinker/Parallel/DWARFLinker.h"
#include "llvm/DWARFLinker/StringPool.h"
#include "llvm/DebugInfo/DWARF/DWARFUnit.h"
Expand Down