LLVM 20.0.0git
DIEAttributeCloner.h
Go to the documentation of this file.
1//===- DIEAttributeCloner.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_DIEATTRIBUTECLONER_H
10#define LLVM_LIB_DWARFLINKER_PARALLEL_DIEATTRIBUTECLONER_H
11
12#include "ArrayList.h"
13#include "DIEGenerator.h"
16#include "DWARFLinkerTypeUnit.h"
17
18namespace llvm {
19namespace dwarf_linker {
20namespace parallel {
21
22/// Information gathered and exchanged between the various
23/// clone*Attr helpers about the attributes of a particular DIE.
25 /// Short Name.
26 StringEntry *Name = nullptr;
27
28 /// Mangled Name.
30
31 /// Does the DIE have an address pointing to live code section?
32 bool HasLiveAddress = false;
33
34 /// Is this DIE only a declaration?
35 bool IsDeclaration = false;
36
37 /// Does the DIE have a ranges attribute?
38 bool HasRanges = false;
39
40 /// Does the DIE have a string offset attribute?
42};
43
44/// This class creates clones of input DIE attributes.
45/// It enumerates attributes of input DIE, creates clone for each
46/// attribute, adds cloned attribute to the output DIE.
48public:
52 std::optional<int64_t> FuncAddressAdjustment,
53 std::optional<int64_t> VarAddressAdjustment,
56 CompileUnit::OutputUnitVariantPtr(OutUnit),
59 }
60
64 std::optional<int64_t> FuncAddressAdjustment,
65 std::optional<int64_t> VarAddressAdjustment,
68 CompileUnit::OutputUnitVariantPtr(OutUnit),
71 }
72
73 /// Clone attributes of input DIE.
74 void clone();
75
76 /// Create abbreviations for the output DIE after all attributes are cloned.
77 unsigned finalizeAbbreviations(bool HasChildrenToClone);
78
79 /// Cannot be used concurrently.
81
82 unsigned getOutOffset() { return AttrOutOffset; }
83
84protected:
89 std::optional<int64_t> FuncAddressAdjustment,
90 std::optional<int64_t> VarAddressAdjustment,
94 OutUnit->getSectionDescriptor(DebugSectionKind::DebugInfo)),
100
101 // Use DW_FORM_strp form for string attributes for DWARF version less than 5
102 // or if output unit is type unit and we need to produce deterministic
103 // result. (We can not generate deterministic results for debug_str_offsets
104 // section when attributes are cloned parallelly).
106 (InUnit.getVersion() < 5) ||
107 (OutUnit.isTypeUnit() &&
110 }
111
112 /// Clone string attribute.
113 size_t
116
117 /// Clone attribute referencing another DIE.
118 size_t
121
122 /// Clone scalar attribute.
123 size_t
126
127 /// Clone block or exprloc attribute.
128 size_t
131
132 /// Clone address attribute.
133 size_t
136
137 /// Returns true if attribute should be skipped.
138 bool
140
141 /// Output DIE.
142 DIE *OutDIE = nullptr;
143
144 /// Input compilation unit.
146
147 /// Output unit(either "plain" compilation unit, either artificial type unit).
149
150 /// .debug_info section descriptor.
152
153 /// Input DIE entry.
155
156 /// Input DIE index.
158
159 /// Output DIE generator.
161
162 /// Relocation adjustment for the function address ranges.
163 std::optional<int64_t> FuncAddressAdjustment;
164
165 /// Relocation adjustment for the variable locations.
166 std::optional<int64_t> VarAddressAdjustment;
167
168 /// Indicates whether InputDieEntry has an location attribute
169 /// containg address expression.
171
172 /// Output offset after all attributes.
173 unsigned AttrOutOffset = 0;
174
175 /// Patches for the cloned attributes.
177
178 /// This flag forces using DW_FORM_strp for string attributes.
179 bool Use_DW_FORM_strp = false;
180};
181
182} // end of namespace parallel
183} // end of namespace dwarf_linker
184} // end of namespace llvm
185
186#endif // LLVM_LIB_DWARFLINKER_PARALLEL_DIEATTRIBUTECLONER_H
A structured debug information entry.
Definition: DIE.h:819
DWARFDebugInfoEntry - A DIE with only the minimum required data.
StringMapEntry - This is used to represent one value that is inserted into a StringMap.
Stores all information related to a compile unit, be it in its original instance of the object file o...
This class creates clones of input DIE attributes.
size_t cloneBlockAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone block or exprloc attribute.
AttributesInfo AttrInfo
Cannot be used concurrently.
CompileUnit & InUnit
Input compilation unit.
bool HasLocationExpressionAddress
Indicates whether InputDieEntry has an location attribute containg address expression.
SectionDescriptor & DebugInfoOutputSection
.debug_info section descriptor.
unsigned finalizeAbbreviations(bool HasChildrenToClone)
Create abbreviations for the output DIE after all attributes are cloned.
unsigned AttrOutOffset
Output offset after all attributes.
DIEGenerator & Generator
Output DIE generator.
size_t cloneScalarAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone scalar attribute.
OffsetsPtrVector PatchesOffsets
Patches for the cloned attributes.
void clone()
Clone attributes of input DIE.
size_t cloneDieRefAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone attribute referencing another DIE.
DIEAttributeCloner(DIE *OutDIE, CompileUnit &InUnit, CompileUnit *OutUnit, const DWARFDebugInfoEntry *InputDieEntry, DIEGenerator &Generator, std::optional< int64_t > FuncAddressAdjustment, std::optional< int64_t > VarAddressAdjustment, bool HasLocationExpressionAddress)
bool shouldSkipAttribute(DWARFAbbreviationDeclaration::AttributeSpec AttrSpec)
Returns true if attribute should be skipped.
size_t cloneStringAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone string attribute.
DIEAttributeCloner(DIE *OutDIE, CompileUnit &InUnit, CompileUnit::OutputUnitVariantPtr OutUnit, const DWARFDebugInfoEntry *InputDieEntry, DIEGenerator &Generator, std::optional< int64_t > FuncAddressAdjustment, std::optional< int64_t > VarAddressAdjustment, bool HasLocationExpressionAddress)
const DWARFDebugInfoEntry * InputDieEntry
Input DIE entry.
std::optional< int64_t > FuncAddressAdjustment
Relocation adjustment for the function address ranges.
CompileUnit::OutputUnitVariantPtr OutUnit
Output unit(either "plain" compilation unit, either artificial type unit).
size_t cloneAddressAttr(const DWARFFormValue &Val, const DWARFAbbreviationDeclaration::AttributeSpec &AttrSpec)
Clone address attribute.
std::optional< int64_t > VarAddressAdjustment
Relocation adjustment for the variable locations.
bool Use_DW_FORM_strp
This flag forces using DW_FORM_strp for string attributes.
DIEAttributeCloner(DIE *OutDIE, CompileUnit &InUnit, TypeUnit *OutUnit, const DWARFDebugInfoEntry *InputDieEntry, DIEGenerator &Generator, std::optional< int64_t > FuncAddressAdjustment, std::optional< int64_t > VarAddressAdjustment, bool HasLocationExpressionAddress)
This class is a helper to create output DIE tree.
Definition: DIEGenerator.h:22
LinkingGlobalData & getGlobalData()
Return global data.
const DWARFLinkerOptions & getOptions() const
Returns linking options.
uint16_t getVersion() const
Return DWARF version.
Type Unit is used to represent an artificial compilation unit which keeps all type information.
uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const
DebugSectionKind
List of tracked debug tables.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
Information gathered and exchanged between the various clone*Attr helpers about the attributes of a p...
bool IsDeclaration
Is this DIE only a declaration?
bool HasRanges
Does the DIE have a ranges attribute?
bool HasLiveAddress
Does the DIE have an address pointing to live code section?
bool HasStringOffsetBaseAttr
Does the DIE have a string offset attribute?
bool AllowNonDeterministicOutput
Allow to generate valid, but non deterministic output.
This structure is used to keep data of the concrete section.