Files
llvm-6502/lib/CodeGen/AsmPrinter/DwarfStringPool.h
Duncan P. N. Exon Smith e3ae958f94 AsmPrinter: Emit the DwarfStringPool offset directly when possible
Change `DwarfStringPool` to calculate byte offsets on-the-fly, and
update `DwarfUnit::getLocalString()` to use a `DIEInteger` instead of a
`DIEDelta` when Dwarf doesn't use relocations (i.e., Mach-O).  This
eliminates another call to `EmitLabelDifference()`, and drops memory
usage from 865 MB down to 861 MB, around 0.5%.

(I'm looking at `llc` memory usage on `verify-uselistorder.lto.opt.bc`;
see r236629 for details.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238114 91177308-0d34-0410-b5e6-96231b3b80d8
2015-05-24 16:14:59 +00:00

68 lines
1.8 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/CodeGen/AsmPrinter.h"
#include "llvm/Support/Allocator.h"
#include <utility>
namespace llvm {
class MCSymbol;
class MCSection;
class StringRef;
// Collection of strings for this unit and assorted symbols.
// A String->Symbol mapping of strings used by indirect
// references.
class DwarfStringPool {
struct EntryTy {
MCSymbol *Symbol;
unsigned Offset;
unsigned Index;
};
StringMap<EntryTy, BumpPtrAllocator &> Pool;
StringRef Prefix;
unsigned NumBytes = 0;
public:
DwarfStringPool(BumpPtrAllocator &A, AsmPrinter &Asm, StringRef Prefix)
: Pool(A), Prefix(Prefix) {}
void emit(AsmPrinter &Asm, MCSection *StrSection,
MCSection *OffsetSection = nullptr);
/// \brief Returns an entry into the string pool with the given
/// string text.
MCSymbol *getSymbol(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).Symbol;
}
/// Get a byte offset into the string pool with the given text.
unsigned getOffset(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).Offset;
}
/// \brief Returns the index into the string pool with the given
/// string text.
unsigned getIndex(AsmPrinter &Asm, StringRef Str) {
return getEntry(Asm, Str).Index;
}
bool empty() const { return Pool.empty(); }
private:
EntryTy &getEntry(AsmPrinter &Asm, StringRef Str);
};
}
#endif