LLVM 20.0.0git
DWARFLinkerGlobalData.h
Go to the documentation of this file.
1//===- DWARFLinkerGlobalData.h ----------------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
10#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
11
12#include "TypePool.h"
16
17namespace llvm {
18
19class DWARFDie;
20
21namespace dwarf_linker {
22namespace parallel {
23
24using MessageHandlerTy = std::function<void(
25 const Twine &Warning, StringRef Context, const DWARFDie *DIE)>;
26
27/// linking options
29 /// DWARF version for the output.
31
32 /// Generate processing log to the standard output.
33 bool Verbose = false;
34
35 /// Print statistics.
36 bool Statistics = false;
37
38 /// Verify the input DWARF.
39 bool VerifyInputDWARF = false;
40
41 /// Do not unique types according to ODR
42 bool NoODR = false;
43
44 /// Update index tables.
46
47 /// Whether we want a static variable to force us to keep its enclosing
48 /// function.
50
51 /// Allow to generate valid, but non deterministic output.
53
54 /// Number of threads.
55 unsigned Threads = 1;
56
57 /// The accelerator table kinds
59
60 /// Prepend path for the clang modules.
61 std::string PrependPath;
62
63 /// input verification handler(it might be called asynchronously).
65 nullptr;
66
67 /// A list of all .swiftinterface files referenced by the debug
68 /// info, mapping Module name to path on disk. The entries need to
69 /// be uniqued and sorted and there are only few entries expected
70 /// per compile unit, which is why this is a std::map.
71 /// this is dsymutil specific fag.
72 ///
73 /// (it might be called asynchronously).
75
76 /// A list of remappings to apply to file paths.
77 ///
78 /// (it might be called asynchronously).
80};
81
82class DWARFLinkerImpl;
83
84/// This class keeps data and services common for the whole linking process.
86 friend DWARFLinkerImpl;
87
88public:
89 /// Returns global per-thread allocator.
91 return Allocator;
92 }
93
94 /// Returns global string pool.
96
97 /// Returns linking options.
98 const DWARFLinkerOptions &getOptions() const { return Options; }
99
100 /// Set warning handler.
102
103 /// Set error handler.
104 void setErrorHandler(MessageHandlerTy Handler) { ErrorHandler = Handler; }
105
106 /// Report warning.
107 void warn(const Twine &Warning, StringRef Context,
108 const DWARFDie *DIE = nullptr) {
109 if (WarningHandler)
110 (WarningHandler)(Warning, Context, DIE);
111 }
112
113 /// Report warning.
114 void warn(Error Warning, StringRef Context, const DWARFDie *DIE = nullptr) {
115 handleAllErrors(std::move(Warning), [&](ErrorInfoBase &Info) {
116 warn(Info.message(), Context, DIE);
117 });
118 }
119
120 /// Report error.
121 void error(const Twine &Err, StringRef Context,
122 const DWARFDie *DIE = nullptr) {
123 if (ErrorHandler)
124 (ErrorHandler)(Err, Context, DIE);
125 }
126
127 /// Report error.
128 void error(Error Err, StringRef Context, const DWARFDie *DIE = nullptr) {
129 handleAllErrors(std::move(Err), [&](ErrorInfoBase &Info) {
130 error(Info.message(), Context, DIE);
131 });
132 }
133
134 /// Set target triple.
136 this->TargetTriple = TargetTriple;
137 }
138
139 /// Optionally return target triple.
140 std::optional<std::reference_wrapper<const Triple>> getTargetTriple() {
141 if (TargetTriple)
142 return std::cref(*TargetTriple);
143
144 return std::nullopt;
145 }
146
147protected:
153
154 /// Triple for output data. May be not set if generation of output
155 /// data is not requested.
156 std::optional<Triple> TargetTriple;
157};
158
159} // end of namespace parallel
160} // end of namespace dwarf_linker
161} // end of namespace llvm
162
163#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERGLOBALDATA_H
Analysis containing CSE Info
Definition: CSEInfo.cpp:27
#define error(X)
A structured debug information entry.
Definition: DIE.h:819
Utility class that carries the DWARF compile/type unit and the debug info entry in an object.
Definition: DWARFDie.h:42
Base class for error info classes.
Definition: Error.h:45
Lightweight error class with error context and mandatory checking.
Definition: Error.h:160
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
std::map< std::string, std::string > ObjectPrefixMapTy
std::function< void(const DWARFFile &File, llvm::StringRef Output)> InputVerificationHandlerTy
std::map< std::string, std::string > SwiftInterfacesMapTy
This class keeps data and services common for the whole linking process.
void warn(const Twine &Warning, StringRef Context, const DWARFDie *DIE=nullptr)
Report warning.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
void warn(Error Warning, StringRef Context, const DWARFDie *DIE=nullptr)
Report warning.
void setErrorHandler(MessageHandlerTy Handler)
Set error handler.
void error(const Twine &Err, StringRef Context, const DWARFDie *DIE=nullptr)
Report error.
llvm::parallel::PerThreadBumpPtrAllocator Allocator
std::optional< Triple > TargetTriple
Triple for output data.
void setTargetTriple(const Triple &TargetTriple)
Set target triple.
void error(Error Err, StringRef Context, const DWARFDie *DIE=nullptr)
Report error.
void setWarningHandler(MessageHandlerTy Handler)
Set warning handler.
StringPool & getStringPool()
Returns global string pool.
std::optional< std::reference_wrapper< const Triple > > getTargetTriple()
Optionally return target triple.
llvm::parallel::PerThreadBumpPtrAllocator & getAllocator()
Returns global per-thread allocator.
std::function< void(const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy
PerThreadAllocator< BumpPtrAllocator > PerThreadBumpPtrAllocator
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void handleAllErrors(Error E, HandlerTs &&... Handlers)
Behaves the same as handleErrors, except that by contract all errors must be handled by the given han...
Definition: Error.h:977
bool KeepFunctionForStatic
Whether we want a static variable to force us to keep its enclosing function.
DWARFLinkerBase::ObjectPrefixMapTy * ObjectPrefixMap
A list of remappings to apply to file paths.
bool Verbose
Generate processing log to the standard output.
DWARFLinkerBase::SwiftInterfacesMapTy * ParseableSwiftInterfaces
A list of all .swiftinterface files referenced by the debug info, mapping Module name to path on disk...
SmallVector< DWARFLinkerBase::AccelTableKind, 1 > AccelTables
The accelerator table kinds.
uint16_t TargetDWARFVersion
DWARF version for the output.
bool NoODR
Do not unique types according to ODR.
bool AllowNonDeterministicOutput
Allow to generate valid, but non deterministic output.
std::string PrependPath
Prepend path for the clang modules.
DWARFLinkerBase::InputVerificationHandlerTy InputVerificationHandler
input verification handler(it might be called asynchronously).