diff --git a/llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h b/llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h index abeba62707c1d8..79c4c07a720a7d 100644 --- a/llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h +++ b/llvm/include/llvm/CodeGen/DwarfStringPoolEntry.h @@ -29,18 +29,16 @@ struct DwarfStringPoolEntry { /// String pool entry reference. class DwarfStringPoolEntryRef { - PointerIntPair *, 1, bool> - MapEntryAndIndexed; + const StringMapEntry *MapEntry = nullptr; const StringMapEntry *getMapEntry() const { - return MapEntryAndIndexed.getPointer(); + return MapEntry; } public: DwarfStringPoolEntryRef() = default; - DwarfStringPoolEntryRef(const StringMapEntry &Entry, - bool Indexed) - : MapEntryAndIndexed(&Entry, Indexed) {} + DwarfStringPoolEntryRef(const StringMapEntry &Entry) + : MapEntry(&Entry) {} explicit operator bool() const { return getMapEntry(); } MCSymbol *getSymbol() const { @@ -48,9 +46,7 @@ class DwarfStringPoolEntryRef { 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; } diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp index a876f8ccace94f..07ae5c8931d069 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfStringPool.cpp @@ -39,7 +39,7 @@ 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, @@ -47,7 +47,7 @@ DwarfStringPool::EntryRef DwarfStringPool::getIndexedEntry(AsmPrinter &Asm, 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, diff --git a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp index db5217469fbae6..7304bfef55cb7a 100644 --- a/llvm/lib/CodeGen/NonRelocatableStringpool.cpp +++ b/llvm/lib/CodeGen/NonRelocatableStringpool.cpp @@ -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) { @@ -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(); diff --git a/llvm/unittests/CodeGen/DIEHashTest.cpp b/llvm/unittests/CodeGen/DIEHashTest.cpp index b6dbb7452aa6a8..b86c36263bd8af 100644 --- a/llvm/unittests/CodeGen/DIEHashTest.cpp +++ b/llvm/unittests/CodeGen/DIEHashTest.cpp @@ -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() {