LLVM: lib/DWARFLinker/Parallel/DWARFLinkerImpl.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9#ifndef LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H

10#define LLVM_LIB_DWARFLINKER_PARALLEL_DWARFLINKERIMPL_H

11

20

21namespace llvm {

24

25

27public:

30

31

32

33

34

35

36

39

41

42

44

45

46

52

53

54

55

56

57

58

62

63

65 GlobalData.Options.Statistics = Statistics;

66 }

67

68

72

73

75

76

78 GlobalData.Options.UpdateIndexTablesOnly = UpdateIndexTablesOnly;

79 }

80

81

82 void

84 GlobalData.Options.AllowNonDeterministicOutput =

85 AllowNonDeterministicOutput;

86 }

87

88

90 GlobalData.Options.KeepFunctionForStatic = KeepFunctionForStatic;

91 }

92

93

97

98

101 GlobalData.Options.AccelTables.emplace_back(Kind);

102 }

103

104

108

109

111

112

113

114 void

116 GlobalData.Options.InputVerificationHandler = Handler;

117 }

118

119

121 GlobalData.Options.ParseableSwiftInterfaces = Map;

122 }

123

124

126 GlobalData.Options.ObjectPrefixMap = Map;

127 }

128

129

131 if ((TargetDWARFVersion < 1) || (TargetDWARFVersion > 5))

133 "unsupported DWARF version: %d",

134 TargetDWARFVersion);

135

136 GlobalData.Options.TargetDWARFVersion = TargetDWARFVersion;

138 }

139

140

141protected:

142

144

145

147

148

150

151

156

158

159

160

163

164

165

170

172 std::unique_ptr Unit;

173 };

175

176

178

179

181

182

184

185

187

188

189

191

193

194

195

196

198

200

201

203

207

208

209

210

211

213 std::string &PCMFile,

214 unsigned Indent, bool Quiet);

215

216

217

218

219

220

221

224 unsigned Indent = 0);

225

226

227

228

230 const std::string &PCMFile,

232 unsigned Indent = 0);

233

234

236

237

240

243

244 for (auto &Unit : InputDWARFFile.Dwarf->compile_units())

245 Size += Unit->getLength();

246

248 }

249

250

252

253

257

258

260

261

263

264

267

272 [](uint64_t LHS, const std::unique_ptr &RHS) {

273 return LHS < RHS->getOrigUnit().getNextUnitOffset();

274 });

275

277 };

278 };

279

280

281

283

284

286

287

289

290

292

294

295

298 StringHandler);

299

300

301

304

305

307

308

310

311

313

314

316

317

319

320

322

323

325

326

328

329

331

332

334

335

336

337

338

339

341

342

345

346

348

349

350

351

352

353

355

356

358

359

361

362

364

365

367

368

370

371

373

374};

375

376}

377}

378}

379

380#endif

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

This file contains support for writing accelerator tables.

static fatal_error_handler_t ErrorHandler

ppc ctr loops PowerPC CTR Loops Verify

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

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

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

StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...

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

Triple - Helper class for working with autoconf configuration names.

This class represents DWARF information for source file and it's address map.

std::map< std::string, std::string > ObjectPrefixMapTy

function_ref< void(const DWARFUnit &Unit)> CompileUnitHandlerTy

std::function< void( const Twine &Warning, StringRef Context, const DWARFDie *DIE)> MessageHandlerTy

AccelTableKind

The kind of accelerator tables to be emitted.

std::map< std::string, std::string > SwiftInterfacesMapTy

std::function< ErrorOr< DWARFFile & >( StringRef ContainerName, StringRef Path)> ObjFileLoaderTy

std::function< void(const DWARFFile &File, llvm::StringRef Output)> InputVerificationHandlerTy

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

Stage

The stages of new compile unit processing.

@ Cleaned

Resources(Input DWARF, Output DWARF tree) are released.

void forEachObjectSectionsSet(function_ref< void(OutputSections &SectionsSet)> SectionsSetHandler)

Enumerates sections for modules, invariant for object files, compile units.

StringDestinationKind

Definition DWARFLinkerImpl.h:293

@ DebugStr

Definition DWARFLinkerImpl.h:293

@ DebugLineStr

Definition DWARFLinkerImpl.h:293

void emitDWARFv5DebugNamesSection(const Triple &TargetTriple)

Emit .debug_names section.

void writeCompileUnitsToTheOutput()

Enumerate all compile units and put their data into the output stream.

friend class DependencyTracker

Definition DWARFLinkerImpl.h:157

void forEachCompileUnit(function_ref< void(CompileUnit *CU)> UnitHandler)

Enumerates all comple units.

void assignOffsetsToStrings()

Enumerate all compile units and assign offsets to their strings.

void assignOffsets()

Enumerate all compile units and assign offsets to their sections and strings.

Error link() override

Link debug info for added files.

Error validateAndUpdateOptions()

Validate specified options.

void writeCommonSectionsToTheOutput()

Enumerate common sections and put their data into the output stream.

void assignOffsetsToSections()

Enumerate all compile units and assign offsets to their sections.

void printStatistic()

Print statistic for processed Debug Info.

void glueCompileUnitsAndWriteToTheOutput()

Take already linked compile units and glue them into single file.

void emitAppleAcceleratorSections(const Triple &TargetTriple)

Emit apple accelerator sections.

void verifyInput(const DWARFFile &File)

Verify input DWARF file.

void forEachCompileAndTypeUnit(function_ref< void(DwarfUnit *CU)> UnitHandler)

Enumerates all compile and type units.

void emitStringSections()

Emit string sections.

DWARFLinkerImpl(MessageHandlerTy ErrorHandler, MessageHandlerTy WarningHandler)

void addObjectFile(DWARFFile &File, ObjFileLoaderTy Loader=nullptr, CompileUnitHandlerTy OnCUDieLoaded=[](const DWARFUnit &) {}) override

Add object file to be linked.

void cleanupDataAfterDWARFOutputIsWritten()

Cleanup data(string pools) after output sections are generated.

void forEachOutputString(function_ref< void(StringDestinationKind, const StringEntry *)> StringHandler)

Enumerates all strings.

void setOutputDWARFHandler(const Triple &TargetTriple, SectionHandlerTy SectionHandler) override

Set output DWARF handler.

Definition DWARFLinkerImpl.h:47

void emitCommonSectionsAndWriteCompileUnitsToTheOutput()

Emit debug sections common for all input files.

void patchOffsetsAndSizes()

Enumerates all patches and update them with the correct values.

Base class for all Dwarf units(Compile unit/Type table unit).

This class keeps data and services common for the whole linking process.

This class keeps contents and offsets to the debug sections.

OutputSections(LinkingGlobalData &GlobalData)

LinkingGlobalData & GlobalData

This class creates a DwarfStringPoolEntry for the corresponding StringEntry.

Type Unit is used to represent an artificial compilation unit which keeps all type information.

An efficient, type-erasing, non-owning reference to a callable.

LinkingGlobalData GlobalData

Definition DWARFLinkerImpl.h:354

std::atomic< size_t > UniqueUnitID

Unique ID for compile unit.

Definition DWARFLinkerImpl.h:340

uint64_t OverallNumberOfCU

Overall compile units number.

Definition DWARFLinkerImpl.h:372

SmallVector< std::unique_ptr< LinkContext > > ObjectContexts

Keeps all linking contexts.

Definition DWARFLinkerImpl.h:363

StringEntryToDwarfStringPoolEntryMap DebugLineStrStrings

DwarfStringPoolEntries for .debug_line_str section.

Definition DWARFLinkerImpl.h:360

SectionHandlerTy SectionHandler

Hanler for output sections.

Definition DWARFLinkerImpl.h:369

std::unique_ptr< TypeUnit > ArtificialTypeUnit

Type unit.

Definition DWARFLinkerImpl.h:347

StringEntryToDwarfStringPoolEntryMap DebugStrStrings

DwarfStringPoolEntries for .debug_str section.

Definition DWARFLinkerImpl.h:357

std::mutex ClangModulesMutex

Definition DWARFLinkerImpl.h:344

OutputSections CommonSections

Common sections.

Definition DWARFLinkerImpl.h:366

StringMap< uint64_t > ClangModules

Mapping the PCM filename to the DwoId.

Definition DWARFLinkerImpl.h:343

void setNumThreads(unsigned NumThreads) override

Use specified number of threads for parallel files linking.

Definition DWARFLinkerImpl.h:94

Error setTargetDWARFVersion(uint16_t TargetDWARFVersion) override

Set target DWARF version.

Definition DWARFLinkerImpl.h:130

void setVerbosity(bool Verbose) override

Allows to generate log of linking process to the standard output.

Definition DWARFLinkerImpl.h:59

void setInputVerificationHandler(InputVerificationHandlerTy Handler) override

Set verification handler which would be used to report verification errors.

Definition DWARFLinkerImpl.h:115

void setObjectPrefixMap(ObjectPrefixMapTy *Map) override

Set prefix map for objects.

Definition DWARFLinkerImpl.h:125

void addAccelTableKind(AccelTableKind Kind) override

Add kind of accelerator tables to be generated.

Definition DWARFLinkerImpl.h:99

void setAllowNonDeterministicOutput(bool AllowNonDeterministicOutput) override

Allow generating valid, but non-deterministic output.

Definition DWARFLinkerImpl.h:83

void setVerifyInputDWARF(bool Verify) override

Verify the input DWARF.

Definition DWARFLinkerImpl.h:69

void setKeepFunctionForStatic(bool KeepFunctionForStatic) override

Set to keep the enclosing function for a static variable.

Definition DWARFLinkerImpl.h:89

void setUpdateIndexTablesOnly(bool UpdateIndexTablesOnly) override

Update index tables only(do not modify rest of DWARF).

Definition DWARFLinkerImpl.h:77

void setSwiftInterfacesMap(SwiftInterfacesMapTy *Map) override

Set map for Swift interfaces.

Definition DWARFLinkerImpl.h:120

void setStatistics(bool Statistics) override

Print statistics to standard output.

Definition DWARFLinkerImpl.h:64

void setNoODR(bool NoODR) override

Do not unique types according to ODR.

Definition DWARFLinkerImpl.h:74

void setPrependPath(StringRef Ppath) override

Set prepend path for clang modules.

Definition DWARFLinkerImpl.h:105

void setEstimatedObjfilesAmount(unsigned ObjFilesNum) override

Set estimated objects files amount, for preliminary data allocation.

std::function< void(std::shared_ptr< SectionDescriptorBase > Section)> SectionHandlerTy

StringMapEntry< EmptyStringSetTag > StringEntry

StringEntry keeps data of the string: the length, external offset and a string body which is placed r...

This is an optimization pass for GlobalISel generic memory operations.

auto upper_bound(R &&Range, T &&Value)

Provide wrappers to std::upper_bound which take ranges instead of having to pass begin/end explicitly...

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

bool is_contained(R &&Range, const E &Element)

Returns true if Element is found in Range.

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

Definition DWARFLinkerImpl.h:152

uint64_t Output

Definition DWARFLinkerImpl.h:154

uint64_t Input

Definition DWARFLinkerImpl.h:153

Keep information for referenced clang module: already loaded DWARF info of the clang module and a Com...

Definition DWARFLinkerImpl.h:166

DWARFFile & File

Definition DWARFLinkerImpl.h:171

RefModuleUnit(DWARFFile &File, std::unique_ptr< CompileUnit > Unit)

std::unique_ptr< CompileUnit > Unit

Definition DWARFLinkerImpl.h:172

RefModuleUnit(const RefModuleUnit &)=delete

uint64_t getInputDebugInfoSize() const

Computes the total size of the debug info.

Definition DWARFLinkerImpl.h:238

bool InterCUProcessingStarted

Flag indicating that all inter-connected units are loaded and the dwarf linking process for these uni...

Definition DWARFLinkerImpl.h:190

bool registerModuleReference(const DWARFDie &CUDie, ObjFileLoaderTy Loader, CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent=0)

If this compile unit is really a skeleton CU that points to a clang module, register it in ClangModul...

Error loadClangModule(ObjFileLoaderTy Loader, const DWARFDie &CUDie, const std::string &PCMFile, CompileUnitHandlerTy OnCUDieLoaded, unsigned Indent=0)

Recursively add the debug info in this clang module .pcm file (and all the modules imported by it in ...

DWARFFile & InputDWARFFile

Object file descriptor.

Definition DWARFLinkerImpl.h:177

SmallVector< RefModuleUnit > ModuleUnitListTy

Definition DWARFLinkerImpl.h:174

LinkContext(LinkingGlobalData &GlobalData, DWARFFile &File, StringMap< uint64_t > &ClangModules, std::atomic< size_t > &UniqueUnitID)

uint64_t OriginalDebugInfoSize

Size of Debug info before optimizing.

Definition DWARFLinkerImpl.h:186

Error emitInvariantSections()

Emit invariant sections.

std::pair< bool, bool > isClangModuleRef(const DWARFDie &CUDie, std::string &PCMFile, unsigned Indent, bool Quiet)

Check whether specified CUDie is a Clang module reference.

void addModulesCompileUnit(RefModuleUnit &&Unit)

Add Compile Unit corresponding to the module.

void emitFDE(uint32_t CIEOffset, uint32_t AddrSize, uint64_t Address, StringRef FDEBytes, SectionDescriptor &Section)

Emit FDE record.

UnitListTy CompileUnits

Set of Compilation Units(may be accessed asynchroniously for reading).

Definition DWARFLinkerImpl.h:180

SmallVector< std::unique_ptr< CompileUnit > > UnitListTy

Definition DWARFLinkerImpl.h:162

void linkSingleCompileUnit(CompileUnit &CU, TypeUnit *ArtificialTypeUnit, enum CompileUnit::Stage DoUntilStage=CompileUnit::Stage::Cleaned)

Link specified compile unit until specified stage.

std::atomic< bool > HasNewInterconnectedCUs

Flag indicating that new inter-connected compilation units were discovered.

Definition DWARFLinkerImpl.h:197

StringMap< uint64_t > & ClangModules

Definition DWARFLinkerImpl.h:192

Error cloneAndEmitDebugFrame()

Clone and emit .debug_frame.

std::atomic< size_t > & UniqueUnitID

Counter for compile units ID.

Definition DWARFLinkerImpl.h:202

std::atomic< bool > HasNewGlobalDependency

Definition DWARFLinkerImpl.h:199

std::function< CompileUnit *(uint64_t)> getUnitForOffset

Definition DWARFLinkerImpl.h:268

ModuleUnitListTy ModulesCompileUnits

Set of Compile Units for modules.

Definition DWARFLinkerImpl.h:183

This structure is used to keep data of the concrete section.