#include "DWARFLinkerCompileUnit.h"
#include "AcceleratorRecordsSaver.h"
#include "DIEAttributeCloner.h"
#include "DIEGenerator.h"
#include "DependencyTracker.h"
#include "SyntheticTypeNameBuilder.h"
#include "llvm/DWARFLinker/Utils.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugAbbrev.h"
#include "llvm/DebugInfo/DWARF/DWARFDebugMacro.h"
#include "llvm/Support/DJB.h"
#include "llvm/Support/FileSystem.h"
#include "llvm/Support/FormatVariadic.h"
#include "llvm/Support/Path.h"
#include <utility>
usingnamespacellvm;
usingnamespacedwarf_linker;
usingnamespacedwarf_linker::parallel;
CompileUnit::CompileUnit(LinkingGlobalData &GlobalData, unsigned ID,
StringRef ClangModuleName, DWARFFile &File,
OffsetToUnitTy UnitFromOffset,
dwarf::FormParams Format, llvm::endianness Endianess)
: … { … }
CompileUnit::CompileUnit(LinkingGlobalData &GlobalData, DWARFUnit &OrigUnit,
unsigned ID, StringRef ClangModuleName,
DWARFFile &File, OffsetToUnitTy UnitFromOffset,
dwarf::FormParams Format, llvm::endianness Endianess)
: … { … }
void CompileUnit::loadLineTable() { … }
void CompileUnit::maybeResetToLoadedStage() { … }
bool CompileUnit::loadInputDIEs() { … }
void CompileUnit::analyzeDWARFStructureRec(const DWARFDebugInfoEntry *DieEntry,
bool IsODRUnavailableFunctionScope) { … }
StringEntry *CompileUnit::getFileName(unsigned FileIdx,
StringPool &GlobalStrings) { … }
void CompileUnit::cleanupDataAfterClonning() { … }
void CompileUnit::analyzeImportedModule(const DWARFDebugInfoEntry *DieEntry) { … }
Error CompileUnit::assignTypeNames(TypePool &TypePoolRef) { … }
Error CompileUnit::assignTypeNamesRec(const DWARFDebugInfoEntry *DieEntry,
SyntheticTypeNameBuilder &NameBuilder) { … }
void CompileUnit::updateDieRefPatchesWithClonedOffsets() { … }
std::optional<UnitEntryPairTy> CompileUnit::resolveDIEReference(
const DWARFFormValue &RefValue,
ResolveInterCUReferencesMode CanResolveInterCUReferences) { … }
std::optional<UnitEntryPairTy> CompileUnit::resolveDIEReference(
const DWARFDebugInfoEntry *DieEntry, dwarf::Attribute Attr,
ResolveInterCUReferencesMode CanResolveInterCUReferences) { … }
void CompileUnit::addFunctionRange(uint64_t FuncLowPc, uint64_t FuncHighPc,
int64_t PcOffset) { … }
void CompileUnit::addLabelLowPc(uint64_t LabelLowPc, int64_t PcOffset) { … }
Error CompileUnit::cloneAndEmitDebugLocations() { … }
void CompileUnit::emitLocations(DebugSectionKind LocationSectionKind) { … }
uint64_t CompileUnit::emitLocListHeader(SectionDescriptor &OutLocationSection) { … }
uint64_t CompileUnit::emitLocListFragment(
const LinkedLocationExpressionsVector &LinkedLocationExpression,
SectionDescriptor &OutLocationSection) { … }
Error CompileUnit::emitDebugAddrSection() { … }
Error CompileUnit::cloneAndEmitRanges() { … }
void CompileUnit::cloneAndEmitRangeList(DebugSectionKind RngSectionKind,
AddressRanges &LinkedFunctionRanges) { … }
uint64_t CompileUnit::emitRangeListHeader(SectionDescriptor &OutRangeSection) { … }
void CompileUnit::emitRangeListFragment(const AddressRanges &LinkedRanges,
SectionDescriptor &OutRangeSection) { … }
void CompileUnit::emitAranges(AddressRanges &LinkedFunctionRanges) { … }
Error CompileUnit::cloneAndEmitDebugMacro() { … }
void CompileUnit::emitMacroTableImpl(const DWARFDebugMacro *MacroTable,
uint64_t OffsetToMacroTable,
bool hasDWARFv5Header) { … }
void CompileUnit::cloneDieAttrExpression(
const DWARFExpression &InputExpression,
SmallVectorImpl<uint8_t> &OutputExpression, SectionDescriptor &Section,
std::optional<int64_t> VarAddressAdjustment,
OffsetsPtrVector &PatchesOffsets) { … }
Error CompileUnit::cloneAndEmit(
std::optional<std::reference_wrapper<const Triple>> TargetTriple,
TypeUnit *ArtificialTypeUnit) { … }
std::pair<DIE *, TypeEntry *> CompileUnit::cloneDIE(
const DWARFDebugInfoEntry *InputDieEntry, TypeEntry *ClonedParentTypeDIE,
uint64_t OutOffset, std::optional<int64_t> FuncAddressAdjustment,
std::optional<int64_t> VarAddressAdjustment, BumpPtrAllocator &Allocator,
TypeUnit *ArtificialTypeUnit) { … }
DIE *CompileUnit::createPlainDIEandCloneAttributes(
const DWARFDebugInfoEntry *InputDieEntry, DIEGenerator &PlainDIEGenerator,
uint64_t &OutOffset, std::optional<int64_t> &FuncAddressAdjustment,
std::optional<int64_t> &VarAddressAdjustment) { … }
DIE *CompileUnit::allocateTypeDie(TypeEntryBody *TypeDescriptor,
DIEGenerator &TypeDIEGenerator,
dwarf::Tag DieTag, bool IsDeclaration,
bool IsParentDeclaration) { … }
TypeEntry *CompileUnit::createTypeDIEandCloneAttributes(
const DWARFDebugInfoEntry *InputDieEntry, DIEGenerator &TypeDIEGenerator,
TypeEntry *ClonedParentTypeDIE, TypeUnit *ArtificialTypeUnit) { … }
Error CompileUnit::cloneAndEmitLineTable(const Triple &TargetTriple) { … }
void CompileUnit::insertLineSequence(std::vector<DWARFDebugLine::Row> &Seq,
std::vector<DWARFDebugLine::Row> &Rows) { … }
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void CompileUnit::DIEInfo::dump() {
llvm::errs() << "{";
llvm::errs() << " Placement: ";
switch (getPlacement()) {
case NotSet:
llvm::errs() << "NotSet";
break;
case TypeTable:
llvm::errs() << "TypeTable";
break;
case PlainDwarf:
llvm::errs() << "PlainDwarf";
break;
case Both:
llvm::errs() << "Both";
break;
}
llvm::errs() << " Keep: " << getKeep();
llvm::errs() << " KeepPlainChildren: " << getKeepPlainChildren();
llvm::errs() << " KeepTypeChildren: " << getKeepTypeChildren();
llvm::errs() << " IsInMouduleScope: " << getIsInMouduleScope();
llvm::errs() << " IsInFunctionScope: " << getIsInFunctionScope();
llvm::errs() << " IsInAnonNamespaceScope: " << getIsInAnonNamespaceScope();
llvm::errs() << " ODRAvailable: " << getODRAvailable();
llvm::errs() << " TrackLiveness: " << getTrackLiveness();
llvm::errs() << "}\n";
}
#endif
std::optional<std::pair<StringRef, StringRef>>
CompileUnit::getDirAndFilenameFromLineTable(
const DWARFFormValue &FileIdxValue) { … }
std::optional<std::pair<StringRef, StringRef>>
CompileUnit::getDirAndFilenameFromLineTable(uint64_t FileIdx) { … }
#define MAX_REFERENCIES_DEPTH …
UnitEntryPairTy UnitEntryPairTy::getNamespaceOrigin() { … }
std::optional<UnitEntryPairTy> UnitEntryPairTy::getParent() { … }
CompileUnit::OutputUnitVariantPtr::OutputUnitVariantPtr(CompileUnit *U)
: … { … }
CompileUnit::OutputUnitVariantPtr::OutputUnitVariantPtr(TypeUnit *U) : … { … }
DwarfUnit *CompileUnit::OutputUnitVariantPtr::operator->() { … }
bool CompileUnit::OutputUnitVariantPtr::isCompileUnit() { … }
bool CompileUnit::OutputUnitVariantPtr::isTypeUnit() { … }
CompileUnit *CompileUnit::OutputUnitVariantPtr::getAsCompileUnit() { … }
TypeUnit *CompileUnit::OutputUnitVariantPtr::getAsTypeUnit() { … }
bool CompileUnit::resolveDependenciesAndMarkLiveness(
bool InterCUProcessingStarted, std::atomic<bool> &HasNewInterconnectedCUs) { … }
bool CompileUnit::updateDependenciesCompleteness() { … }
void CompileUnit::verifyDependencies() { … }
ArrayRef<dwarf::Attribute> dwarf_linker::parallel::getODRAttributes() { … }