Skip to content

Commit

Permalink
[Debuginfo][DWARF][NFC] Refactor DwarfStringPoolEntryRef - remove isI…
Browse files Browse the repository at this point in the history
…ndexed().

This patch is extraction from the https://reviews.llvm.org/D126883.
It removes DwarfStringPoolEntryRef::isIndexed() and isIndexed bit
since they are not used.

Differential Revision: https://reviews.llvm.org/D126958
  • Loading branch information
avl-llvm committed Jun 5, 2022
1 parent 1bfc5e7 commit 501d5b2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 14 deletions.
12 changes: 4 additions & 8 deletions llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h
Expand Up @@ -29,28 +29,24 @@ struct DwarfStringPoolEntry {

/// String pool entry reference.
class DwarfStringPoolEntryRef {
PointerIntPair<const StringMapEntry<DwarfStringPoolEntry> *, 1, bool>
MapEntryAndIndexed;
const StringMapEntry<DwarfStringPoolEntry> *MapEntry = nullptr;

const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
return MapEntryAndIndexed.getPointer();
return MapEntry;
}

public:
DwarfStringPoolEntryRef() = default;
DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry,
bool Indexed)
: MapEntryAndIndexed(&Entry, Indexed) {}
DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry)
: MapEntry(&Entry) {}

explicit operator bool() const { return getMapEntry(); }
MCSymbol *getSymbol() const {
assert(getMapEntry()->second.Symbol && "No symbol available!");
return getMapEntry()->second.Symbol;
}
uint64_t getOffset() const { return getMapEntry()->second.Offset; }
bool isIndexed() const { return MapEntryAndIndexed.getInt(); }
unsigned getIndex() const {
assert(isIndexed());
assert(getMapEntry()->getValue().isIndexed());
return getMapEntry()->second.Index;
}
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp
Expand Up @@ -39,15 +39,15 @@ DwarfStringPool::getEntryImpl(AsmPrinter &Asm, StringRef Str) {
DwarfStringPool::EntryRef DwarfStringPool::getEntry(AsmPrinter &Asm,
StringRef Str) {
auto &MapEntry = getEntryImpl(Asm, Str);
return EntryRef(MapEntry, false);
return EntryRef(MapEntry);
}

DwarfStringPool::EntryRef DwarfStringPool::getIndexedEntry(AsmPrinter &Asm,
StringRef Str) {
auto &MapEntry = getEntryImpl(Asm, Str);
if (!MapEntry.getValue().isIndexed())
MapEntry.getValue().Index = NumIndexedStrings++;
return EntryRef(MapEntry, true);
return EntryRef(MapEntry);
}

void DwarfStringPool::emitStringOffsetsTableHeader(AsmPrinter &Asm,
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/CodeGen/NonRelocatableStringpool.cpp
Expand Up @@ -25,7 +25,7 @@ DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
Entry.Symbol = nullptr;
CurrentEndOffset += S.size() + 1;
}
return DwarfStringPoolEntryRef(*I.first, true);
return DwarfStringPoolEntryRef(*I.first);
}

StringRef NonRelocatableStringpool::internString(StringRef S) {
Expand All @@ -44,7 +44,7 @@ NonRelocatableStringpool::getEntriesForEmission() const {
Result.reserve(Strings.size());
for (const auto &E : Strings)
if (E.getValue().isIndexed())
Result.emplace_back(E, true);
Result.emplace_back(E);
llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
const DwarfStringPoolEntryRef B) {
return A.getIndex() < B.getIndex();
Expand Down
4 changes: 2 additions & 2 deletions llvm/unittests/CodeGen/DIEHashTest.cpp
Expand Up @@ -41,8 +41,8 @@ class DIEHashTest : public testing::Test {
public:
DIEString getString(StringRef S) {
DwarfStringPoolEntry Entry = {nullptr, 1, 1};
return DIEString(DwarfStringPoolEntryRef(
*Pool.insert(std::make_pair(S, Entry)).first, Entry.isIndexed()));
return DIEString(
DwarfStringPoolEntryRef(*Pool.insert(std::make_pair(S, Entry)).first));
}

AsmPrinter *getAsmPrinter() {
Expand Down

0 comments on commit 501d5b2

Please sign in to comment.