Path: blob/main/contrib/llvm-project/llvm/lib/DWARFLinker/Parallel/DWARFLinkerGlobalData.h
35292 views
//===- DWARFLinkerGlobalData.h ----------------------------------*- C++ -*-===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H9#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H1011#include "TypePool.h"12#include "llvm/DWARFLinker/Parallel/DWARFLinker.h"13#include "llvm/DWARFLinker/StringPool.h"14#include "llvm/Support/PerThreadBumpPtrAllocator.h"1516namespace llvm {1718class DWARFDie;1920namespace dwarf_linker {21namespace parallel {2223using MessageHandlerTy = std::function<void(24const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;2526/// linking options27struct DWARFLinkerOptions {28/// DWARF version for the output.29uint16_t TargetDWARFVersion = 0;3031/// Generate processing log to the standard output.32bool Verbose = false;3334/// Print statistics.35bool Statistics = false;3637/// Verify the input DWARF.38bool VerifyInputDWARF = false;3940/// Do not unique types according to ODR41bool NoODR = false;4243/// Update index tables.44bool UpdateIndexTablesOnly = false;4546/// Whether we want a static variable to force us to keep its enclosing47/// function.48bool KeepFunctionForStatic = false;4950/// Allow to generate valid, but non deterministic output.51bool AllowNonDeterministicOutput = false;5253/// Number of threads.54unsigned Threads = 1;5556/// The accelerator table kinds57SmallVector<DWARFLinkerBase::AccelTableKind, 1> AccelTables;5859/// Prepend path for the clang modules.60std::string PrependPath;6162/// input verification handler(it might be called asynchronously).63DWARFLinkerBase::InputVerificationHandlerTy InputVerificationHandler =64nullptr;6566/// A list of all .swiftinterface files referenced by the debug67/// info, mapping Module name to path on disk. The entries need to68/// be uniqued and sorted and there are only few entries expected69/// per compile unit, which is why this is a std::map.70/// this is dsymutil specific fag.71///72/// (it might be called asynchronously).73DWARFLinkerBase::SwiftInterfacesMapTy *ParseableSwiftInterfaces = nullptr;7475/// A list of remappings to apply to file paths.76///77/// (it might be called asynchronously).78DWARFLinkerBase::ObjectPrefixMapTy *ObjectPrefixMap = nullptr;79};8081class DWARFLinkerImpl;8283/// This class keeps data and services common for the whole linking process.84class LinkingGlobalData {85friend DWARFLinkerImpl;8687public:88/// Returns global per-thread allocator.89llvm::parallel::PerThreadBumpPtrAllocator &getAllocator() {90return Allocator;91}9293/// Returns global string pool.94StringPool &getStringPool() { return Strings; }9596/// Returns linking options.97const DWARFLinkerOptions &getOptions() const { return Options; }9899/// Set warning handler.100void setWarningHandler(MessageHandlerTy Handler) { WarningHandler = Handler; }101102/// Set error handler.103void setErrorHandler(MessageHandlerTy Handler) { ErrorHandler = Handler; }104105/// Report warning.106void warn(const Twine &Warning, StringRef Context,107const DWARFDie *DIE = nullptr) {108if (WarningHandler)109(WarningHandler)(Warning, Context, DIE);110}111112/// Report warning.113void warn(Error Warning, StringRef Context, const DWARFDie *DIE = nullptr) {114handleAllErrors(std::move(Warning), [&](ErrorInfoBase &Info) {115warn(Info.message(), Context, DIE);116});117}118119/// Report error.120void error(const Twine &Err, StringRef Context,121const DWARFDie *DIE = nullptr) {122if (ErrorHandler)123(ErrorHandler)(Err, Context, DIE);124}125126/// Report error.127void error(Error Err, StringRef Context, const DWARFDie *DIE = nullptr) {128handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) {129error(Info.message(), Context, DIE);130});131}132133/// Set target triple.134void setTargetTriple(const Triple &TargetTriple) {135this->TargetTriple = TargetTriple;136}137138/// Optionally return target triple.139std::optional<std::reference_wrapper<const Triple>> getTargetTriple() {140if (TargetTriple)141return std::cref(*TargetTriple);142143return std::nullopt;144}145146protected:147llvm::parallel::PerThreadBumpPtrAllocator Allocator;148StringPool Strings;149DWARFLinkerOptions Options;150MessageHandlerTy WarningHandler;151MessageHandlerTy ErrorHandler;152153/// Triple for output data. May be not set if generation of output154/// data is not requested.155std::optional<Triple> TargetTriple;156};157158} // end of namespace parallel159} // end of namespace dwarf_linker160} // end of namespace llvm161162#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H163164165