
We have been creating many ConcatInputSections with identical values due to .subsections_via_symbols. This diff factors out the identical values into a Shared struct, to reduce memory consumption and make copying cheaper. I also changed `callSiteCount` from a uint32_t to a 31-bit field to save an extra word. All in all, this takes InputSection from 120 to 72 bytes (and ConcatInputSection from 160 to 112 bytes), i.e. 30% size reduction in ConcatInputSection. Numbers for linking chromium_framework on my 3.2 GHz 16-Core Intel Xeon W: N Min Max Median Avg Stddev x 20 4.14 4.24 4.18 4.183 0.027548999 + 20 4.04 4.11 4.075 4.0775 0.018027756 Difference at 95.0% confidence -0.1055 +/- 0.0149005 -2.52211% +/- 0.356215% (Student's t, pooled s = 0.0232803) Reviewed By: #lld-macho, thakis Differential Revision: https://reviews.llvm.org/D105305
44 lines
1.5 KiB
C++
44 lines
1.5 KiB
C++
//===- DWARF.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 "Dwarf.h"
|
|
#include "InputFiles.h"
|
|
#include "InputSection.h"
|
|
#include "OutputSegment.h"
|
|
|
|
#include <memory>
|
|
|
|
using namespace lld;
|
|
using namespace lld::macho;
|
|
using namespace llvm;
|
|
|
|
std::unique_ptr<DwarfObject> DwarfObject::create(ObjFile *obj) {
|
|
auto dObj = std::make_unique<DwarfObject>();
|
|
bool hasDwarfInfo = false;
|
|
// LLD only needs to extract the source file path from the debug info, so we
|
|
// initialize DwarfObject with just the sections necessary to get that path.
|
|
// The debugger will locate the debug info via the object file paths that we
|
|
// emit in our STABS symbols, so we don't need to process & emit them
|
|
// ourselves.
|
|
for (const InputSection *isec : obj->debugSections) {
|
|
if (StringRef *s =
|
|
StringSwitch<StringRef *>(isec->getName())
|
|
.Case(section_names::debugInfo, &dObj->infoSection.Data)
|
|
.Case(section_names::debugAbbrev, &dObj->abbrevSection)
|
|
.Case(section_names::debugStr, &dObj->strSection)
|
|
.Default(nullptr)) {
|
|
*s = toStringRef(isec->data);
|
|
hasDwarfInfo = true;
|
|
}
|
|
}
|
|
|
|
if (hasDwarfInfo)
|
|
return dObj;
|
|
return nullptr;
|
|
}
|