mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-07 12:30:57 +00:00
23332c50c1
Summary: The accelerator tables use the debug_str section to store their strings. However, they do not support the indirect method of access that is available for the debug_info section (DW_FORM_strx et al.). Currently our code is assuming that all strings can/will be referenced indirectly, and puts all of them into the debug_str_offsets section. This is generally true for regular (unsplit) dwarf, but in the DWO case, most of the strings in the debug_str section will only be used from the accelerator tables. Therefore the contents of the debug_str_offsets section will be largely unused and bloating the main executable. This patch rectifies this by teaching the DwarfStringPool to differentiate between strings accessed directly and indirectly. When a user inserts a string into the pool it has to declare whether that string will be referenced directly or not. If at least one user requsts indirect access, that string will be assigned an index ID and put into debug_str_offsets table. Otherwise, the offset table is skipped. This approach reduces the overall binary size (when compiled with -gdwarf-5 -gsplit-dwarf) in my tests by about 2% (debug_str_offsets is shrunk by 99%). Reviewers: probinson, dblaikie, JDevlieghere Subscribers: aprantl, mgrang, llvm-commits Differential Revision: https://reviews.llvm.org/D49493 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339122 91177308-0d34-0410-b5e6-96231b3b80d8
68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
//===- llvm/CodeGen/DwarfStringPool.h - Dwarf Debug Framework ---*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
|
|
#define LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
|
|
|
|
#include "llvm/ADT/StringMap.h"
|
|
#include "llvm/ADT/StringRef.h"
|
|
#include "llvm/CodeGen/DwarfStringPoolEntry.h"
|
|
#include "llvm/Support/Allocator.h"
|
|
|
|
namespace llvm {
|
|
|
|
class AsmPrinter;
|
|
class MCSection;
|
|
class MCSymbol;
|
|
|
|
// Collection of strings for this unit and assorted symbols.
|
|
// A String->Symbol mapping of strings used by indirect
|
|
// references.
|
|
class DwarfStringPool {
|
|
using EntryTy = DwarfStringPoolEntry;
|
|
|
|
StringMap<EntryTy, BumpPtrAllocator &> Pool;
|
|
StringRef Prefix;
|
|
unsigned NumBytes = 0;
|
|
unsigned NumIndexedStrings = 0;
|
|
bool ShouldCreateSymbols;
|
|
|
|
StringMapEntry<EntryTy> &getEntryImpl(AsmPrinter &Asm, StringRef Str);
|
|
|
|
public:
|
|
using EntryRef = DwarfStringPoolEntryRef;
|
|
|
|
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix);
|
|
|
|
void emitStringOffsetsTableHeader(AsmPrinter &Asm, MCSection *OffsetSection,
|
|
MCSymbol *StartSym);
|
|
|
|
void emit(AsmPrinter &Asm, MCSection *StrSection,
|
|
MCSection *OffsetSection = nullptr,
|
|
bool UseRelativeOffsets = false);
|
|
|
|
bool empty() const { return Pool.empty(); }
|
|
|
|
unsigned size() const { return Pool.size(); }
|
|
|
|
unsigned getNumIndexedStrings() const { return NumIndexedStrings; }
|
|
|
|
/// Get a reference to an entry in the string pool.
|
|
EntryRef getEntry(AsmPrinter &Asm, StringRef Str);
|
|
|
|
/// Same as getEntry, except that you can use EntryRef::getIndex to obtain a
|
|
/// unique ID of this entry (e.g., for use in indexed forms like
|
|
/// DW_FORM_strx).
|
|
EntryRef getIndexedEntry(AsmPrinter &Asm, StringRef Str);
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif // LLVM_LIB_CODEGEN_ASMPRINTER_DWARFSTRINGPOOL_H
|