AsmPrinter: Store abbreviation data directly in DIE and DIEValue

Stop storing a `DIEAbbrev` in `DIE`, since the data fits neatly inside
the `DIEValue` list.  Besides being a cleaner data structure (avoiding
the parallel arrays), this gives us more freedom to rearrange the
`DIEValue` list.

This fixes the temporary memory regression from 845 MB up to 879 MB, and
drops it further to 829 MB for a net memory decrease of around 1.9%
(incremental decrease around 5.7%).

(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@238364 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Duncan P. N. Exon Smith
2015-05-27 22:31:41 +00:00
parent 09fe4bf794
commit 611a2f2322
9 changed files with 128 additions and 98 deletions

View File

@ -24,21 +24,27 @@ DwarfFile::~DwarfFile() {}
// Define a unique number for the abbreviation.
//
void DwarfFile::assignAbbrevNumber(DIEAbbrev &Abbrev) {
// Check the set for priors.
DIEAbbrev *InSet = AbbreviationsSet.GetOrInsertNode(&Abbrev);
DIEAbbrev &DwarfFile::assignAbbrevNumber(DIE &Die) {
FoldingSetNodeID ID;
DIEAbbrev Abbrev = Die.generateAbbrev();
Abbrev.Profile(ID);
// If it's newly added.
if (InSet == &Abbrev) {
// Add to abbreviation list.
Abbreviations.push_back(&Abbrev);
// Assign the vector position + 1 as its number.
Abbrev.setNumber(Abbreviations.size());
} else {
// Assign existing abbreviation number.
Abbrev.setNumber(InSet->getNumber());
void *InsertPos;
if (DIEAbbrev *Existing =
AbbreviationsSet.FindNodeOrInsertPos(ID, InsertPos)) {
Die.setAbbrevNumber(Existing->getNumber());
return *Existing;
}
// Move the abbreviation to the heap and assign a number.
DIEAbbrev *New = new (AbbrevAllocator) DIEAbbrev(std::move(Abbrev));
Abbreviations.push_back(New);
New->setNumber(Abbreviations.size());
Die.setAbbrevNumber(Abbreviations.size());
// Store it for lookup.
AbbreviationsSet.InsertNode(New, InsertPos);
return *New;
}
void DwarfFile::addUnit(std::unique_ptr<DwarfUnit> U) {
@ -83,10 +89,7 @@ void DwarfFile::computeSizeAndOffsets() {
// CU. It returns the offset after laying out the DIE.
unsigned DwarfFile::computeSizeAndOffset(DIE &Die, unsigned Offset) {
// Record the abbreviation.
assignAbbrevNumber(Die.getAbbrev());
// Get the abbreviation for this DIE.
const DIEAbbrev &Abbrev = Die.getAbbrev();
const DIEAbbrev &Abbrev = assignAbbrevNumber(Die);
// Set DIE offset
Die.setOffset(Offset);