mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
d33177a252
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 llvm-svn: 339122
73 lines
2.2 KiB
C++
73 lines
2.2 KiB
C++
//===- llvm/CodeGen/DwarfStringPoolEntry.h - String pool entry --*- C++ -*-===//
|
|
//
|
|
// The LLVM Compiler Infrastructure
|
|
//
|
|
// This file is distributed under the University of Illinois Open Source
|
|
// License. See LICENSE.TXT for details.
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
|
|
#define LLVM_CODEGEN_DWARFSTRINGPOOLENTRY_H
|
|
|
|
#include "llvm/ADT/PointerIntPair.h"
|
|
#include "llvm/ADT/StringMap.h"
|
|
|
|
namespace llvm {
|
|
|
|
class MCSymbol;
|
|
|
|
/// Data for a string pool entry.
|
|
struct DwarfStringPoolEntry {
|
|
static constexpr unsigned NotIndexed = -1;
|
|
|
|
MCSymbol *Symbol;
|
|
unsigned Offset;
|
|
unsigned Index;
|
|
|
|
bool isIndexed() const { return Index != NotIndexed; }
|
|
};
|
|
|
|
/// String pool entry reference.
|
|
class DwarfStringPoolEntryRef {
|
|
PointerIntPair<const StringMapEntry<DwarfStringPoolEntry> *, 1, bool>
|
|
MapEntryAndIndexed;
|
|
|
|
const StringMapEntry<DwarfStringPoolEntry> *getMapEntry() const {
|
|
return MapEntryAndIndexed.getPointer();
|
|
}
|
|
|
|
public:
|
|
DwarfStringPoolEntryRef() = default;
|
|
DwarfStringPoolEntryRef(const StringMapEntry<DwarfStringPoolEntry> &Entry,
|
|
bool Indexed)
|
|
: MapEntryAndIndexed(&Entry, Indexed) {}
|
|
|
|
explicit operator bool() const { return getMapEntry(); }
|
|
MCSymbol *getSymbol() const {
|
|
assert(getMapEntry()->second.Symbol && "No symbol available!");
|
|
return getMapEntry()->second.Symbol;
|
|
}
|
|
unsigned 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;
|
|
}
|
|
StringRef getString() const { return getMapEntry()->first(); }
|
|
/// Return the entire string pool entry for convenience.
|
|
DwarfStringPoolEntry getEntry() const { return getMapEntry()->getValue(); }
|
|
|
|
bool operator==(const DwarfStringPoolEntryRef &X) const {
|
|
return getMapEntry() == X.getMapEntry();
|
|
}
|
|
bool operator!=(const DwarfStringPoolEntryRef &X) const {
|
|
return getMapEntry() != X.getMapEntry();
|
|
}
|
|
};
|
|
|
|
} // end namespace llvm
|
|
|
|
#endif
|