mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-30 14:50:30 +00:00
076ea9fc78
Summary: This patch relands D71271. The problem with D71271 is that it has cyclic dependency: CodeGen->AsmPrinter->DebugInfoDWARF->CodeGen. To avoid cyclic dependency this patch puts implementation for DWARFOptimizer into separate library: lib/DWARFLinker. Thus the difference between this patch and D71271 is in that DWARFOptimizer renamed into DWARFLinker and it`s files are put into lib/DWARFLinker. Reviewers: JDevlieghere, friss, dblaikie, aprantl Reviewed By: JDevlieghere Subscribers: thegameg, merge_guards_bot, probinson, mgorny, hiraditya, llvm-commits Tags: #llvm, #debug-info Differential Revision: https://reviews.llvm.org/D71839
55 lines
1.7 KiB
C++
55 lines
1.7 KiB
C++
//===-- NonRelocatableStringpool.cpp --------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/CodeGen/NonRelocatableStringpool.h"
|
|
|
|
namespace llvm {
|
|
|
|
DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
|
|
if (S.empty() && !Strings.empty())
|
|
return EmptyString;
|
|
|
|
if (Translator)
|
|
S = Translator(S);
|
|
auto I = Strings.insert({S, DwarfStringPoolEntry()});
|
|
auto &Entry = I.first->second;
|
|
if (I.second || !Entry.isIndexed()) {
|
|
Entry.Index = NumEntries++;
|
|
Entry.Offset = CurrentEndOffset;
|
|
Entry.Symbol = nullptr;
|
|
CurrentEndOffset += S.size() + 1;
|
|
}
|
|
return DwarfStringPoolEntryRef(*I.first, true);
|
|
}
|
|
|
|
StringRef NonRelocatableStringpool::internString(StringRef S) {
|
|
DwarfStringPoolEntry Entry{nullptr, 0, DwarfStringPoolEntry::NotIndexed};
|
|
|
|
if (Translator)
|
|
S = Translator(S);
|
|
|
|
auto InsertResult = Strings.insert({S, Entry});
|
|
return InsertResult.first->getKey();
|
|
}
|
|
|
|
std::vector<DwarfStringPoolEntryRef>
|
|
NonRelocatableStringpool::getEntriesForEmission() const {
|
|
std::vector<DwarfStringPoolEntryRef> Result;
|
|
Result.reserve(Strings.size());
|
|
for (const auto &E : Strings)
|
|
if (E.getValue().isIndexed())
|
|
Result.emplace_back(E, true);
|
|
llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
|
|
const DwarfStringPoolEntryRef B) {
|
|
return A.getIndex() < B.getIndex();
|
|
});
|
|
return Result;
|
|
}
|
|
|
|
} // namespace llvm
|