1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00
llvm-mirror/tools/dsymutil/LinkUtils.h
Jonas Devlieghere 5e66aeab68 [dsymutil] Add option to print statistics about the .debug_info size.
This patch adds statistics about the contribution of each object file to
the linked debug info. When --statistics is passed to dsymutil, it
prints a table after linking as illustrated below.

It lists the object file name, the size of the debug info in the object
file in bytes, and the absolute size contribution to the linked dSYM and
the percentage difference. The table is sorted by the output size, so
the object files contributing the most to the link are listed first.

.debug_info section size (in bytes)
-------------------------------------------------------------------------------
Filename                                           Object         dSYM   Change
-------------------------------------------------------------------------------
basic2.macho.x86_64.o                                210b         165b  -24.00%
basic3.macho.x86_64.o                                177b         150b  -16.51%
basic1.macho.x86_64.o                                125b         129b    3.15%
-------------------------------------------------------------------------------
Total                                                512b         444b  -14.23%
-------------------------------------------------------------------------------

Differential revision: https://reviews.llvm.org/D79513
2020-05-06 19:48:45 -07:00

108 lines
2.7 KiB
C++

//===- tools/dsymutil/LinkUtils.h - Dwarf linker utilities ------*- C++ -*-===//
//
// 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
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
#define LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H
#include "SymbolMap.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Remarks/RemarkFormat.h"
#include "llvm/Support/VirtualFileSystem.h"
#include "llvm/Support/WithColor.h"
#include "llvm/DWARFLinker/DWARFLinker.h"
#include "llvm/DWARFLinker/DWARFStreamer.h"
#include <string>
namespace llvm {
namespace dsymutil {
struct LinkOptions {
/// Verbosity
bool Verbose = false;
/// Statistics
bool Statistics = false;
/// Skip emitting output
bool NoOutput = false;
/// Do not unique types according to ODR
bool NoODR = false;
/// Update
bool Update = false;
/// Minimize
bool Minimize = false;
/// Do not check swiftmodule timestamp
bool NoTimestamp = false;
/// Number of threads.
unsigned Threads = 1;
// Output file type.
OutputFileType FileType = OutputFileType::Object;
/// The accelerator table kind
AccelTableKind TheAccelTableKind;
/// -oso-prepend-path
std::string PrependPath;
/// The -object-prefix-map.
std::map<std::string, std::string> ObjectPrefixMap;
/// The Resources directory in the .dSYM bundle.
Optional<std::string> ResourceDir;
/// Symbol map translator.
SymbolMapTranslator Translator;
/// Virtual File System.
llvm::IntrusiveRefCntPtr<llvm::vfs::FileSystem> VFS =
vfs::getRealFileSystem();
/// Fields used for linking and placing remarks into the .dSYM bundle.
/// @{
/// Number of debug maps processed in total.
unsigned NumDebugMaps = 0;
/// -remarks-prepend-path: prepend a path to all the external remark file
/// paths found in remark metadata.
std::string RemarksPrependPath;
/// The output format of the remarks.
remarks::Format RemarksFormat = remarks::Format::Bitstream;
/// @}
LinkOptions() = default;
};
inline void warn(Twine Warning, Twine Context = {}) {
WithColor::warning() << Warning + "\n";
if (!Context.isTriviallyEmpty())
WithColor::note() << Twine("while processing ") + Context + "\n";
}
inline bool error(Twine Error, Twine Context = {}) {
WithColor::error() << Error + "\n";
if (!Context.isTriviallyEmpty())
WithColor::note() << Twine("while processing ") + Context + "\n";
return false;
}
} // end namespace dsymutil
} // end namespace llvm
#endif // LLVM_TOOLS_DSYMUTIL_LINKOPTIONS_H