LLVM: lib/DWARFLinker/Classic/DWARFLinkerCompileUnit.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

15

16namespace llvm {

17

20

21#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)

24 llvm::errs() << " AddrAdjust: " << AddrAdjust << '\n';

27 llvm::errs() << " ParentIdx: " << ParentIdx << '\n';

29 llvm::errs() << " InDebugMap: " << InDebugMap << '\n';

30 llvm::errs() << " Prune: " << Prune << '\n';

31 llvm::errs() << " Incomplete: " << Incomplete << '\n';

32 llvm::errs() << " InModuleScope: " << InModuleScope << '\n';

33 llvm::errs() << " ODRMarkingDone: " << ODRMarkingDone << '\n';

34 llvm::errs() << " UnclonedReference: " << UnclonedReference << '\n';

36}

37#endif

38

39

41 while (Idx) {

42 if (U.getOrigUnit().getDIEAtIndex(Idx).getTag() == dwarf::DW_TAG_subprogram)

43 return true;

44 Idx = U.getInfo(Idx).ParentIdx;

45 }

46 return false;

47}

48

50 if (!Language) {

53 }

54 return Language;

55}

56

58 if (SysRoot.empty()) {

61 }

62 return SysRoot;

63}

64

66 unsigned Idx = 0;

67

68 for (auto &I : Info) {

69

70 I.Keep = I.Prune;

71 auto DIE = OrigUnit.getDIEAtIndex(Idx++);

73

74

75

76

77 if (DIE.getTag() != dwarf::DW_TAG_variable &&

78 DIE.getTag() != dwarf::DW_TAG_constant)

79 continue;

80

81 std::optional Value;

82 if (!(Value = DIE.find(dwarf::DW_AT_location))) {

83 if ((Value = DIE.find(dwarf::DW_AT_const_value)) &&

85 I.InDebugMap = true;

86 continue;

87 }

88

89 if (auto ExprLockBlock = Value->getAsBlock()) {

90

92 U->getContext().isLittleEndian(),

93 U->getAddressByteSize());

95 U->getFormParams().Format);

96

98 (It != Expression.end()) && I.InDebugMap; ++It) {

100 ++NextIt;

101

102 switch (It->getCode()) {

103 case dwarf::DW_OP_const2u:

104 case dwarf::DW_OP_const4u:

105 case dwarf::DW_OP_const8u:

106 case dwarf::DW_OP_const2s:

107 case dwarf::DW_OP_const4s:

108 case dwarf::DW_OP_const8s:

110 NextIt->getCode() != dwarf::DW_OP_form_tls_address)

111 break;

112 [[fallthrough]];

113 case dwarf::DW_OP_constx:

114 case dwarf::DW_OP_addr:

115 case dwarf::DW_OP_addrx:

116 I.InDebugMap = true;

117 break;

118 default:

119

120 break;

121 }

122 }

123 }

124 }

125}

126

128 NextUnitOffset = StartOffset;

129 if (NewUnit) {

130 NextUnitOffset += (DwarfVersion >= 5) ? 12 : 11;

131 NextUnitOffset += NewUnit->getUnitDie().getSize();

132 }

133 return NextUnitOffset;

134}

135

136

137

140 ForwardDIEReferences.emplace_back(Die, RefUnit, Ctxt, Attr);

141}

142

144 for (const auto &Ref : ForwardDIEReferences) {

145 DIE *RefDie;

149 std::tie(RefDie, RefUnit, Ctxt, Attr) = Ref;

152 "Canonical die offset is not set");

154 } else {

155 assert(RefDie->getOffset() && "Referenced die offset is not set");

157 }

158 }

159}

160

162 Labels.insert({LabelLowPc, PcOffset});

163}

164

166 int64_t PcOffset) {

167 Ranges.insert({FuncLowPc, FuncHighPc}, PcOffset);

168 if (LowPc)

169 LowPc = std::min(*LowPc, FuncLowPc + PcOffset);

170 else

171 LowPc = FuncLowPc + PcOffset;

172 this->HighPc = std::max(HighPc, FuncHighPc + PcOffset);

173}

174

176 if (Die.getTag() == dwarf::DW_TAG_compile_unit) {

177 UnitRangeAttribute = Attr;

178 return;

179 }

180

181 RangeAttributes.emplace_back(Attr);

182}

183

185 LocationAttributes.emplace_back(Attr);

186}

187

189 StmtSeqListAttributes.emplace_back(Attr);

190}

191

194 Namespaces.emplace_back(Name, Die);

195}

196

199 bool SkipPubSection) {

200 ObjC.emplace_back(Name, Die, SkipPubSection);

201}

202

205 bool SkipPubSection) {

206 Pubnames.emplace_back(Name, Die, SkipPubSection);

207}

208

211 bool ObjcClassImplementation,

212 uint32_t QualifiedNameHash) {

213 Pubtypes.emplace_back(Name, Die, QualifiedNameHash, ObjcClassImplementation);

214}

215

216}

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

#define LLVM_DUMP_METHOD

Mark debug helper function definitions like dump() that should not be stripped from debug builds.

A structured debug information entry.

unsigned getOffset() const

Get the compile/type unit relative offset of this DIE.

dwarf::Tag getTag() const

Utility class that carries the DWARF compile/type unit and the debug info entry in an object.

An iterator to go through the expression operations.

DWARFDie getUnitDIE(bool ExtractUnitDIEOnly=true)

DwarfStringPoolEntryRef: Dwarf string pool entry reference.

Class representing an expression and its matching format.

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

LLVM Value Representation.

Stores all information relating to a compile unit, be it in its original instance in the object file ...

LLVM_ABI void addFunctionRange(uint64_t LowPC, uint64_t HighPC, int64_t PCOffset)

Add a function range [LowPC, HighPC) that is relocated by applying offset PCOffset.

Definition DWARFLinkerCompileUnit.cpp:165

LLVM_ABI void noteStmtSeqListAttribute(PatchLocation Attr)

Definition DWARFLinkerCompileUnit.cpp:188

LLVM_ABI void fixupForwardReferences()

Apply all fixups recorded by noteForwardReference().

Definition DWARFLinkerCompileUnit.cpp:143

LLVM_ABI void noteForwardReference(DIE *Die, const CompileUnit *RefUnit, DeclContext *Ctxt, PatchLocation Attr)

Keep track of a forward reference to DIE Die in RefUnit by Attr.

Definition DWARFLinkerCompileUnit.cpp:138

LLVM_ABI void noteLocationAttribute(PatchLocation Attr)

Keep track of a location attribute pointing to a location list in the debug_loc section.

Definition DWARFLinkerCompileUnit.cpp:184

LLVM_ABI void addNameAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name, bool SkipPubnamesSection=false)

Add a name accelerator entry for Die with Name.

Definition DWARFLinkerCompileUnit.cpp:203

LLVM_ABI void addNamespaceAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name)

Add a name accelerator entry for Die with Name.

Definition DWARFLinkerCompileUnit.cpp:192

uint64_t getStartOffset() const

LLVM_ABI uint16_t getLanguage()

Definition DWARFLinkerCompileUnit.cpp:49

LLVM_ABI StringRef getSysRoot()

Return the DW_AT_LLVM_sysroot of the compile unit or an empty StringRef.

Definition DWARFLinkerCompileUnit.cpp:57

LLVM_ABI void noteRangeAttribute(const DIE &Die, PatchLocation Attr)

Keep track of a DW_AT_range attribute that we will need to patch up later.

Definition DWARFLinkerCompileUnit.cpp:175

LLVM_ABI void addObjCAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name, bool SkipPubnamesSection=false)

Add various accelerator entries for Die with Name which is stored in the string table at Offset.

Definition DWARFLinkerCompileUnit.cpp:197

LLVM_ABI void addTypeAccelerator(const DIE *Die, DwarfStringPoolEntryRef Name, bool ObjcClassImplementation, uint32_t QualifiedNameHash)

Add a type accelerator entry for Die with Name which is stored in the string table at Offset.

Definition DWARFLinkerCompileUnit.cpp:209

DWARFUnit & getOrigUnit() const

LLVM_ABI uint64_t computeNextUnitOffset(uint16_t DwarfVersion)

Compute the end offset for this unit.

Definition DWARFLinkerCompileUnit.cpp:127

LLVM_ABI void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset)

Add the low_pc of a label that is relocated by applying offset PCOffset.

Definition DWARFLinkerCompileUnit.cpp:161

LLVM_ABI void markEverythingAsKept()

Mark every DIE in this unit as kept.

Definition DWARFLinkerCompileUnit.cpp:65

CompileUnit(DWARFUnit &OrigUnit, unsigned ID, bool CanUseODR, StringRef ClangModuleName)

A DeclContext is a named program scope that is used for ODR uniquing of types.

bool hasCanonicalDIE() const

uint32_t getCanonicalDIEOffset() const

StringRef toStringRef(const std::optional< DWARFFormValue > &V, StringRef Default={})

Take an optional DWARFFormValue and try to extract a string value from it.

std::optional< uint64_t > toUnsigned(const std::optional< DWARFFormValue > &V)

Take an optional DWARFFormValue and try to extract an unsigned constant.

This is an optimization pass for GlobalISel generic memory operations.

auto formatv(bool Validate, const char *Fmt, Ts &&...Vals)

static bool inFunctionScope(CompileUnit &U, unsigned Idx)

Check if the DIE at Idx is in the scope of a function.

Definition DWARFLinkerCompileUnit.cpp:40

LLVM_ABI raw_fd_ostream & errs()

This returns a reference to a raw_ostream for standard error.

@ Ref

The access may reference the value stored in memory.

FunctionAddr VTableAddr uintptr_t uintptr_t Data

StringRef toStringRef(bool B)

Construct a string ref from a boolean.

@ Keep

No function return thunk.

LLVM_DUMP_METHOD void dump()

void set(uint64_t New) const