LLVM: include/llvm/DWARFLinker/Classic/DWARFLinkerCompileUnit.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_DWARFLINKER_CLASSIC_DWARFLINKERCOMPILEUNIT_H

10#define LLVM_DWARFLINKER_CLASSIC_DWARFLINKERCOMPILEUNIT_H

11

17#include

18

19namespace llvm {

22

24

25

26

28

29

30

31

32

33

34

35

36

40

45

48 const auto &Old = *I;

49 assert(Old.getType() == DIEValue::isInteger);

51 }

52

55 return I->getDIEInteger().getValue();

56 }

57};

58

62

63

64

66public:

67

69

71

72

74

75

77

78

80

81

83

84

86

87

89

90

92

93

95

96

98

99

101

102

104

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

107#endif

108 };

109

112 : OrigUnit(OrigUnit), ID(ID), ClangModuleName(ClangModuleName) {

113 Info.resize(OrigUnit.getNumDIEs());

114

115 auto CUDie = OrigUnit.getUnitDIE(false);

116 if (!CUDie) {

117 HasODR = false;

118 return;

119 }

120 if (auto Lang = dwarf::toUnsigned(CUDie.find(dwarf::DW_AT_language)))

121 HasODR = CanUseODR && (*Lang == dwarf::DW_LANG_C_plus_plus ||

122 *Lang == dwarf::DW_LANG_C_plus_plus_03 ||

123 *Lang == dwarf::DW_LANG_C_plus_plus_11 ||

124 *Lang == dwarf::DW_LANG_C_plus_plus_14 ||

125 *Lang == dwarf::DW_LANG_ObjC_plus_plus);

126 else

127 HasODR = false;

128 }

129

131

133

134 void createOutputDIE() { NewUnit.emplace(OrigUnit.getUnitDIE().getTag()); }

135

137 if (NewUnit)

139 return nullptr;

140 }

141

143

144 bool hasODR() const { return HasODR; }

145 bool isClangModule() const { return !ClangModuleName.empty(); }

147

149

151

154

157 return Info[Idx];

158 }

159

163

164 std::optional<uint64_t> getLowPc() const { return LowPc; }

167

169

171

173 return UnitRangeAttribute;

174 }

175

177 return LocationAttributes;

178 }

179

180

181

183 return StmtSeqListAttributes;

184 }

185

186

187

188

190

191

192

193

195

196

197

198

199

202

203

205

206

207

209

210

211

213 int64_t PCOffset);

214

215

217

218

219

221

222

223

225

226

229

230

232 bool SkipPubnamesSection = false);

233

234

235

236

238 bool SkipPubnamesSection = false);

239

240

241

243 bool ObjcClassImplementation,

245

247

249

250

252

253

255

256

258

259

261

265

271 };

272

273 const std::vector &getPubnames() const { return Pubnames; }

274 const std::vector &getPubtypes() const { return Pubtypes; }

275 const std::vector &getNamespaces() const { return Namespaces; }

276 const std::vector &getObjC() const { return ObjC; }

277

280

281private:

283 unsigned ID;

284 std::vector Info;

285 std::optional NewUnit;

286 MCSymbol *LabelBegin = nullptr;

287

290

291 std::optional<uint64_t> LowPc;

293

294

295

296

297

298

299

300 std::vector<

301 std::tuple<DIE *, const CompileUnit *, DeclContext *, PatchLocation>>

302 ForwardDIEReferences;

303

304

305

306

308

309

311

312

313

314

316 std::optional UnitRangeAttribute;

317

318

319

320

321

322

323

325

326

327

328

329

331

332

333

334

335 std::vector Pubnames;

336 std::vector Pubtypes;

337 std::vector Namespaces;

338 std::vector ObjC;

339

340

341

342 bool HasODR;

343

344

346

347

348 std::string SysRoot;

349

350

351 std::string ClangModuleName;

352};

353

354}

355}

356}

357

358#endif

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

Analysis containing CSE Info

#define LLVM_DUMP_METHOD

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

This file defines the DenseMap class.

AddressRangesMap class maps values to the address ranges.

A structured debug information entry.

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

uint32_t getDIEIndex(const DWARFDebugInfoEntry *Die) const

Return the index of a Die entry inside the unit's DIE vector.

DwarfStringPoolEntryRef: Dwarf string pool entry reference.

MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...

This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.

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

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

Definition DWARFLinkerCompileUnit.h:65

const std::vector< AccelInfo > & getNamespaces() const

Definition DWARFLinkerCompileUnit.h:275

const std::vector< AccelInfo > & getPubnames() const

Definition DWARFLinkerCompileUnit.h:273

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.

LLVM_ABI void noteStmtSeqListAttribute(PatchLocation Attr)

const std::vector< AccelInfo > & getPubtypes() const

Definition DWARFLinkerCompileUnit.h:274

const std::vector< AccelInfo > & getObjC() const

Definition DWARFLinkerCompileUnit.h:276

LLVM_ABI void fixupForwardReferences()

Apply all fixups recorded by noteForwardReference().

const DIEInfo & getInfo(unsigned Idx) const

Definition DWARFLinkerCompileUnit.h:153

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.

LLVM_ABI void noteLocationAttribute(PatchLocation Attr)

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

std::optional< uint64_t > getLowPc() const

Definition DWARFLinkerCompileUnit.h:164

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

Add a name accelerator entry for Die with Name.

const StmtSeqListAttributesTy & getStmtSeqListAttributes() const

Definition DWARFLinkerCompileUnit.h:182

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

Add a name accelerator entry for Die with Name.

uint64_t getStartOffset() const

Definition DWARFLinkerCompileUnit.h:160

DIEInfo & getInfo(const DWARFDie &Die)

Definition DWARFLinkerCompileUnit.h:155

DIE * getOutputUnitDIE() const

Definition DWARFLinkerCompileUnit.h:136

uint64_t getNextUnitOffset() const

Definition DWARFLinkerCompileUnit.h:161

LLVM_ABI uint16_t getLanguage()

uint64_t getHighPc() const

Definition DWARFLinkerCompileUnit.h:165

LLVM_ABI StringRef getSysRoot()

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

DIEInfo & getInfo(unsigned Idx)

Definition DWARFLinkerCompileUnit.h:152

std::optional< PatchLocation > getUnitRangesAttribute() const

Definition DWARFLinkerCompileUnit.h:172

void setStartOffset(uint64_t DebugInfoSize)

Definition DWARFLinkerCompileUnit.h:162

void createOutputDIE()

Definition DWARFLinkerCompileUnit.h:134

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.

void setLabelBegin(MCSymbol *S)

Definition DWARFLinkerCompileUnit.h:279

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.

bool hasLabelAt(uint64_t Addr) const

Definition DWARFLinkerCompileUnit.h:166

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.

DWARFUnit & getOrigUnit() const

Definition DWARFLinkerCompileUnit.h:130

const LocListAttributesTy & getLocationAttributes() const

Definition DWARFLinkerCompileUnit.h:176

bool isClangModule() const

Definition DWARFLinkerCompileUnit.h:145

LLVM_ABI uint64_t computeNextUnitOffset(uint16_t DwarfVersion)

Compute the end offset for this unit.

MCSymbol * getLabelBegin()

Definition DWARFLinkerCompileUnit.h:278

const RangesTy & getFunctionRanges() const

Definition DWARFLinkerCompileUnit.h:168

LLVM_ABI void addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset)

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

LLVM_ABI void markEverythingAsKept()

Mark every DIE in this unit as kept.

bool hasODR() const

Definition DWARFLinkerCompileUnit.h:144

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

Definition DWARFLinkerCompileUnit.h:110

unsigned getUniqueID() const

Definition DWARFLinkerCompileUnit.h:132

const RngListAttributesTy & getRangesAttributes()

Definition DWARFLinkerCompileUnit.h:170

dwarf::Tag getTag() const

Definition DWARFLinkerCompileUnit.h:142

const std::string & getClangModuleName() const

Definition DWARFLinkerCompileUnit.h:150

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

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

SmallVector< PatchLocation > RngListAttributesTy

Definition DWARFLinkerCompileUnit.h:59

SmallVector< PatchLocation > StmtSeqListAttributesTy

Definition DWARFLinkerCompileUnit.h:61

AddressRangesMap RangesTy

Mapped value in the address map is the offset to apply to the linked address.

Definition DWARFLinkerCompileUnit.h:27

SmallVector< PatchLocation > LocListAttributesTy

Definition DWARFLinkerCompileUnit.h:60

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.

Hold the input and output of the debug info size in bytes.

AccelInfo(DwarfStringPoolEntryRef Name, const DIE *Die, uint32_t QualifiedNameHash, bool ObjCClassIsImplementation)

Definition DWARFLinkerCompileUnit.h:266

AccelInfo(DwarfStringPoolEntryRef Name, const DIE *Die, bool SkipPubSection=false)

Definition DWARFLinkerCompileUnit.h:262

DwarfStringPoolEntryRef Name

Name of the entry.

Definition DWARFLinkerCompileUnit.h:248

uint32_t QualifiedNameHash

Hash of the fully qualified name.

Definition DWARFLinkerCompileUnit.h:254

bool ObjcClassImplementation

Is this an ObjC class implementation?

Definition DWARFLinkerCompileUnit.h:260

bool SkipPubSection

Emit this entry only in the apple_* sections.

Definition DWARFLinkerCompileUnit.h:257

const DIE * Die

DIE this entry describes.

Definition DWARFLinkerCompileUnit.h:251

Information gathered about a DIE in the object file.

Definition DWARFLinkerCompileUnit.h:68

uint32_t ParentIdx

The index of this DIE's parent.

Definition DWARFLinkerCompileUnit.h:79

bool Prune

Is this a pure forward declaration we can strip?

Definition DWARFLinkerCompileUnit.h:88

bool ODRMarkingDone

Is ODR marking done?

Definition DWARFLinkerCompileUnit.h:97

int64_t AddrAdjust

Address offset to apply to the described entity.

Definition DWARFLinkerCompileUnit.h:70

bool HasLocationExpressionAddr

Is this a variable with a location attribute referencing address?

Definition DWARFLinkerCompileUnit.h:103

bool InDebugMap

Was this DIE's entity found in the map?

Definition DWARFLinkerCompileUnit.h:85

DIE * Clone

Cloned version of that DIE.

Definition DWARFLinkerCompileUnit.h:76

LLVM_DUMP_METHOD void dump()

bool UnclonedReference

Is this a reference to a DIE that hasn't been cloned yet?

Definition DWARFLinkerCompileUnit.h:100

bool InModuleScope

Is DIE in the clang module scope?

Definition DWARFLinkerCompileUnit.h:94

bool Incomplete

Does DIE transitively refer an incomplete decl?

Definition DWARFLinkerCompileUnit.h:91

DeclContext * Ctxt

ODR Declaration context.

Definition DWARFLinkerCompileUnit.h:73

bool Keep

Is the DIE part of the linked output?

Definition DWARFLinkerCompileUnit.h:82

void set(uint64_t New) const

Definition DWARFLinkerCompileUnit.h:46

uint64_t get() const

Definition DWARFLinkerCompileUnit.h:53

PatchLocation(DIE::value_iterator I, int64_t Reloc)

Definition DWARFLinkerCompileUnit.h:43

DIE::value_iterator I

Definition DWARFLinkerCompileUnit.h:38

PatchLocation(DIE::value_iterator I)

Definition DWARFLinkerCompileUnit.h:42

int64_t RelocAdjustment

Definition DWARFLinkerCompileUnit.h:39