#include "llvm/IR/DebugInfoMetadata.h"
#include "LLVMContextImpl.h"
#include "MetadataImpl.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/StringSwitch.h"
#include "llvm/BinaryFormat/Dwarf.h"
#include "llvm/IR/DebugProgramInstruction.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Type.h"
#include "llvm/IR/Value.h"
#include <numeric>
#include <optional>
usingnamespacellvm;
namespace llvm {
cl::opt<bool> EnableFSDiscriminator(
"enable-fs-discriminator", cl::Hidden,
cl::desc("Enable adding flow sensitive discriminators"));
}
uint32_t DIType::getAlignInBits() const { … }
const DIExpression::FragmentInfo DebugVariable::DefaultFragment = …;
DebugVariable::DebugVariable(const DbgVariableIntrinsic *DII)
: … { … }
DebugVariable::DebugVariable(const DbgVariableRecord *DVR)
: … { … }
DebugVariableAggregate::DebugVariableAggregate(const DbgVariableIntrinsic *DVI)
: … { … }
DILocation::DILocation(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned Column, ArrayRef<Metadata *> MDs,
bool ImplicitCode)
: … { … }
static void adjustColumn(unsigned &Column) { … }
DILocation *DILocation::getImpl(LLVMContext &Context, unsigned Line,
unsigned Column, Metadata *Scope,
Metadata *InlinedAt, bool ImplicitCode,
StorageType Storage, bool ShouldCreate) { … }
DILocation *DILocation::getMergedLocations(ArrayRef<DILocation *> Locs) { … }
DILocation *DILocation::getMergedLocation(DILocation *LocA, DILocation *LocB) { … }
std::optional<unsigned>
DILocation::encodeDiscriminator(unsigned BD, unsigned DF, unsigned CI) { … }
void DILocation::decodeDiscriminator(unsigned D, unsigned &BD, unsigned &DF,
unsigned &CI) { … }
dwarf::Tag DINode::getTag() const { … }
DINode::DIFlags DINode::getFlag(StringRef Flag) { … }
StringRef DINode::getFlagString(DIFlags Flag) { … }
DINode::DIFlags DINode::splitFlags(DIFlags Flags,
SmallVectorImpl<DIFlags> &SplitFlags) { … }
DIScope *DIScope::getScope() const { … }
StringRef DIScope::getName() const { … }
#ifndef NDEBUG
static bool isCanonical(const MDString *S) {
return !S || !S->getString().empty();
}
#endif
dwarf::Tag GenericDINode::getTag() const { … }
GenericDINode *GenericDINode::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Header,
ArrayRef<Metadata *> DwarfOps,
StorageType Storage, bool ShouldCreate) { … }
void GenericDINode::recalculateHash() { … }
#define UNWRAP_ARGS_IMPL(...) …
#define UNWRAP_ARGS(ARGS) …
#define DEFINE_GETIMPL_LOOKUP(CLASS, ARGS) …
#define DEFINE_GETIMPL_STORE(CLASS, ARGS, OPS) …
#define DEFINE_GETIMPL_STORE_NO_OPS(CLASS, ARGS) …
#define DEFINE_GETIMPL_STORE_NO_CONSTRUCTOR_ARGS(CLASS, OPS) …
#define DEFINE_GETIMPL_STORE_N(CLASS, ARGS, OPS, NUM_OPS) …
DISubrange::DISubrange(LLVMContext &C, StorageType Storage,
ArrayRef<Metadata *> Ops)
: … { … }
DISubrange *DISubrange::getImpl(LLVMContext &Context, int64_t Count, int64_t Lo,
StorageType Storage, bool ShouldCreate) { … }
DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
int64_t Lo, StorageType Storage,
bool ShouldCreate) { … }
DISubrange *DISubrange::getImpl(LLVMContext &Context, Metadata *CountNode,
Metadata *LB, Metadata *UB, Metadata *Stride,
StorageType Storage, bool ShouldCreate) { … }
DISubrange::BoundType DISubrange::getCount() const { … }
DISubrange::BoundType DISubrange::getLowerBound() const { … }
DISubrange::BoundType DISubrange::getUpperBound() const { … }
DISubrange::BoundType DISubrange::getStride() const { … }
DIGenericSubrange::DIGenericSubrange(LLVMContext &C, StorageType Storage,
ArrayRef<Metadata *> Ops)
: … { … }
DIGenericSubrange *DIGenericSubrange::getImpl(LLVMContext &Context,
Metadata *CountNode, Metadata *LB,
Metadata *UB, Metadata *Stride,
StorageType Storage,
bool ShouldCreate) { … }
DIGenericSubrange::BoundType DIGenericSubrange::getCount() const { … }
DIGenericSubrange::BoundType DIGenericSubrange::getLowerBound() const { … }
DIGenericSubrange::BoundType DIGenericSubrange::getUpperBound() const { … }
DIGenericSubrange::BoundType DIGenericSubrange::getStride() const { … }
DIEnumerator::DIEnumerator(LLVMContext &C, StorageType Storage,
const APInt &Value, bool IsUnsigned,
ArrayRef<Metadata *> Ops)
: … { … }
DIEnumerator *DIEnumerator::getImpl(LLVMContext &Context, const APInt &Value,
bool IsUnsigned, MDString *Name,
StorageType Storage, bool ShouldCreate) { … }
DIBasicType *DIBasicType::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, uint64_t SizeInBits,
uint32_t AlignInBits, unsigned Encoding,
DIFlags Flags, StorageType Storage,
bool ShouldCreate) { … }
std::optional<DIBasicType::Signedness> DIBasicType::getSignedness() const { … }
DIStringType *DIStringType::getImpl(LLVMContext &Context, unsigned Tag,
MDString *Name, Metadata *StringLength,
Metadata *StringLengthExp,
Metadata *StringLocationExp,
uint64_t SizeInBits, uint32_t AlignInBits,
unsigned Encoding, StorageType Storage,
bool ShouldCreate) { … }
DIType *DIDerivedType::getClassType() const { … }
uint32_t DIDerivedType::getVBPtrOffset() const { … }
Constant *DIDerivedType::getStorageOffsetInBits() const { … }
Constant *DIDerivedType::getConstant() const { … }
Constant *DIDerivedType::getDiscriminantValue() const { … }
DIDerivedType *DIDerivedType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits,
std::optional<unsigned> DWARFAddressSpace,
std::optional<PtrAuthData> PtrAuthData, DIFlags Flags, Metadata *ExtraData,
Metadata *Annotations, StorageType Storage, bool ShouldCreate) { … }
std::optional<DIDerivedType::PtrAuthData>
DIDerivedType::getPtrAuthData() const { … }
DICompositeType *DICompositeType::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *File,
unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
uint32_t AlignInBits, uint64_t OffsetInBits, DIFlags Flags,
Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
Metadata *TemplateParams, MDString *Identifier, Metadata *Discriminator,
Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
Metadata *Rank, Metadata *Annotations, StorageType Storage,
bool ShouldCreate) { … }
DICompositeType *DICompositeType::buildODRType(
LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator,
Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
Metadata *Rank, Metadata *Annotations) { … }
DICompositeType *DICompositeType::getODRType(
LLVMContext &Context, MDString &Identifier, unsigned Tag, MDString *Name,
Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
DIFlags Flags, Metadata *Elements, unsigned RuntimeLang,
Metadata *VTableHolder, Metadata *TemplateParams, Metadata *Discriminator,
Metadata *DataLocation, Metadata *Associated, Metadata *Allocated,
Metadata *Rank, Metadata *Annotations) { … }
DICompositeType *DICompositeType::getODRTypeIfExists(LLVMContext &Context,
MDString &Identifier) { … }
DISubroutineType::DISubroutineType(LLVMContext &C, StorageType Storage,
DIFlags Flags, uint8_t CC,
ArrayRef<Metadata *> Ops)
: … { … }
DISubroutineType *DISubroutineType::getImpl(LLVMContext &Context, DIFlags Flags,
uint8_t CC, Metadata *TypeArray,
StorageType Storage,
bool ShouldCreate) { … }
DIFile::DIFile(LLVMContext &C, StorageType Storage,
std::optional<ChecksumInfo<MDString *>> CS, MDString *Src,
ArrayRef<Metadata *> Ops)
: … { … }
static const char *ChecksumKindName[DIFile::CSK_Last] = …;
StringRef DIFile::getChecksumKindAsString(ChecksumKind CSKind) { … }
std::optional<DIFile::ChecksumKind>
DIFile::getChecksumKind(StringRef CSKindStr) { … }
DIFile *DIFile::getImpl(LLVMContext &Context, MDString *Filename,
MDString *Directory,
std::optional<DIFile::ChecksumInfo<MDString *>> CS,
MDString *Source, StorageType Storage,
bool ShouldCreate) { … }
DICompileUnit::DICompileUnit(LLVMContext &C, StorageType Storage,
unsigned SourceLanguage, bool IsOptimized,
unsigned RuntimeVersion, unsigned EmissionKind,
uint64_t DWOId, bool SplitDebugInlining,
bool DebugInfoForProfiling, unsigned NameTableKind,
bool RangesBaseAddress, ArrayRef<Metadata *> Ops)
: … { … }
DICompileUnit *DICompileUnit::getImpl(
LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
MDString *Producer, bool IsOptimized, MDString *Flags,
unsigned RuntimeVersion, MDString *SplitDebugFilename,
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *GlobalVariables, Metadata *ImportedEntities, Metadata *Macros,
uint64_t DWOId, bool SplitDebugInlining, bool DebugInfoForProfiling,
unsigned NameTableKind, bool RangesBaseAddress, MDString *SysRoot,
MDString *SDK, StorageType Storage, bool ShouldCreate) { … }
std::optional<DICompileUnit::DebugEmissionKind>
DICompileUnit::getEmissionKind(StringRef Str) { … }
std::optional<DICompileUnit::DebugNameTableKind>
DICompileUnit::getNameTableKind(StringRef Str) { … }
const char *DICompileUnit::emissionKindString(DebugEmissionKind EK) { … }
const char *DICompileUnit::nameTableKindString(DebugNameTableKind NTK) { … }
DISubprogram::DISubprogram(LLVMContext &C, StorageType Storage, unsigned Line,
unsigned ScopeLine, unsigned VirtualIndex,
int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags,
ArrayRef<Metadata *> Ops)
: … { … }
DISubprogram::DISPFlags
DISubprogram::toSPFlags(bool IsLocalToUnit, bool IsDefinition, bool IsOptimized,
unsigned Virtuality, bool IsMainSubprogram) { … }
DISubprogram *DILocalScope::getSubprogram() const { … }
DILocalScope *DILocalScope::getNonLexicalBlockFileScope() const { … }
DILocalScope *DILocalScope::cloneScopeForSubprogram(
DILocalScope &RootScope, DISubprogram &NewSP, LLVMContext &Ctx,
DenseMap<const MDNode *, MDNode *> &Cache) { … }
DISubprogram::DISPFlags DISubprogram::getFlag(StringRef Flag) { … }
StringRef DISubprogram::getFlagString(DISPFlags Flag) { … }
DISubprogram::DISPFlags
DISubprogram::splitFlags(DISPFlags Flags,
SmallVectorImpl<DISPFlags> &SplitFlags) { … }
DISubprogram *DISubprogram::getImpl(
LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line, Metadata *Type,
unsigned ScopeLine, Metadata *ContainingType, unsigned VirtualIndex,
int ThisAdjustment, DIFlags Flags, DISPFlags SPFlags, Metadata *Unit,
Metadata *TemplateParams, Metadata *Declaration, Metadata *RetainedNodes,
Metadata *ThrownTypes, Metadata *Annotations, MDString *TargetFuncName,
StorageType Storage, bool ShouldCreate) { … }
bool DISubprogram::describes(const Function *F) const { … }
DILexicalBlockBase::DILexicalBlockBase(LLVMContext &C, unsigned ID,
StorageType Storage,
ArrayRef<Metadata *> Ops)
: … { … }
DILexicalBlock *DILexicalBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *File, unsigned Line,
unsigned Column, StorageType Storage,
bool ShouldCreate) { … }
DILexicalBlockFile *DILexicalBlockFile::getImpl(LLVMContext &Context,
Metadata *Scope, Metadata *File,
unsigned Discriminator,
StorageType Storage,
bool ShouldCreate) { … }
DINamespace::DINamespace(LLVMContext &Context, StorageType Storage,
bool ExportSymbols, ArrayRef<Metadata *> Ops)
: … { … }
DINamespace *DINamespace::getImpl(LLVMContext &Context, Metadata *Scope,
MDString *Name, bool ExportSymbols,
StorageType Storage, bool ShouldCreate) { … }
DICommonBlock::DICommonBlock(LLVMContext &Context, StorageType Storage,
unsigned LineNo, ArrayRef<Metadata *> Ops)
: … { … }
DICommonBlock *DICommonBlock::getImpl(LLVMContext &Context, Metadata *Scope,
Metadata *Decl, MDString *Name,
Metadata *File, unsigned LineNo,
StorageType Storage, bool ShouldCreate) { … }
DIModule::DIModule(LLVMContext &Context, StorageType Storage, unsigned LineNo,
bool IsDecl, ArrayRef<Metadata *> Ops)
: … { … }
DIModule *DIModule::getImpl(LLVMContext &Context, Metadata *File,
Metadata *Scope, MDString *Name,
MDString *ConfigurationMacros,
MDString *IncludePath, MDString *APINotesFile,
unsigned LineNo, bool IsDecl, StorageType Storage,
bool ShouldCreate) { … }
DITemplateTypeParameter::DITemplateTypeParameter(LLVMContext &Context,
StorageType Storage,
bool IsDefault,
ArrayRef<Metadata *> Ops)
: … { … }
DITemplateTypeParameter *
DITemplateTypeParameter::getImpl(LLVMContext &Context, MDString *Name,
Metadata *Type, bool isDefault,
StorageType Storage, bool ShouldCreate) { … }
DITemplateValueParameter *DITemplateValueParameter::getImpl(
LLVMContext &Context, unsigned Tag, MDString *Name, Metadata *Type,
bool isDefault, Metadata *Value, StorageType Storage, bool ShouldCreate) { … }
DIGlobalVariable *
DIGlobalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
MDString *LinkageName, Metadata *File, unsigned Line,
Metadata *Type, bool IsLocalToUnit, bool IsDefinition,
Metadata *StaticDataMemberDeclaration,
Metadata *TemplateParams, uint32_t AlignInBits,
Metadata *Annotations, StorageType Storage,
bool ShouldCreate) { … }
DILocalVariable *
DILocalVariable::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line, Metadata *Type,
unsigned Arg, DIFlags Flags, uint32_t AlignInBits,
Metadata *Annotations, StorageType Storage,
bool ShouldCreate) { … }
DIVariable::DIVariable(LLVMContext &C, unsigned ID, StorageType Storage,
signed Line, ArrayRef<Metadata *> Ops,
uint32_t AlignInBits)
: … { … }
std::optional<uint64_t> DIVariable::getSizeInBits() const { … }
DILabel::DILabel(LLVMContext &C, StorageType Storage, unsigned Line,
ArrayRef<Metadata *> Ops)
: … { … }
DILabel *DILabel::getImpl(LLVMContext &Context, Metadata *Scope, MDString *Name,
Metadata *File, unsigned Line, StorageType Storage,
bool ShouldCreate) { … }
DIExpression *DIExpression::getImpl(LLVMContext &Context,
ArrayRef<uint64_t> Elements,
StorageType Storage, bool ShouldCreate) { … }
bool DIExpression::isEntryValue() const { … }
bool DIExpression::startsWithDeref() const { … }
bool DIExpression::isDeref() const { … }
DIAssignID *DIAssignID::getImpl(LLVMContext &Context, StorageType Storage,
bool ShouldCreate) { … }
unsigned DIExpression::ExprOperand::getSize() const { … }
bool DIExpression::isValid() const { … }
bool DIExpression::isImplicit() const { … }
bool DIExpression::isComplex() const { … }
bool DIExpression::isSingleLocationExpression() const { … }
std::optional<ArrayRef<uint64_t>>
DIExpression::getSingleLocationExpressionElements() const { … }
const DIExpression *
DIExpression::convertToUndefExpression(const DIExpression *Expr) { … }
const DIExpression *
DIExpression::convertToVariadicExpression(const DIExpression *Expr) { … }
std::optional<const DIExpression *>
DIExpression::convertToNonVariadicExpression(const DIExpression *Expr) { … }
void DIExpression::canonicalizeExpressionOps(SmallVectorImpl<uint64_t> &Ops,
const DIExpression *Expr,
bool IsIndirect) { … }
bool DIExpression::isEqualExpression(const DIExpression *FirstExpr,
bool FirstIndirect,
const DIExpression *SecondExpr,
bool SecondIndirect) { … }
std::optional<DIExpression::FragmentInfo>
DIExpression::getFragmentInfo(expr_op_iterator Start, expr_op_iterator End) { … }
std::optional<uint64_t> DIExpression::getActiveBits(DIVariable *Var) { … }
void DIExpression::appendOffset(SmallVectorImpl<uint64_t> &Ops,
int64_t Offset) { … }
bool DIExpression::extractIfOffset(int64_t &Offset) const { … }
bool DIExpression::extractLeadingOffset(
int64_t &OffsetInBytes, SmallVectorImpl<uint64_t> &RemainingOps) const { … }
bool DIExpression::hasAllLocationOps(unsigned N) const { … }
const DIExpression *DIExpression::extractAddressClass(const DIExpression *Expr,
unsigned &AddrClass) { … }
DIExpression *DIExpression::prepend(const DIExpression *Expr, uint8_t Flags,
int64_t Offset) { … }
DIExpression *DIExpression::appendOpsToArg(const DIExpression *Expr,
ArrayRef<uint64_t> Ops,
unsigned ArgNo, bool StackValue) { … }
DIExpression *DIExpression::replaceArg(const DIExpression *Expr,
uint64_t OldArg, uint64_t NewArg) { … }
DIExpression *DIExpression::prependOpcodes(const DIExpression *Expr,
SmallVectorImpl<uint64_t> &Ops,
bool StackValue, bool EntryValue) { … }
DIExpression *DIExpression::append(const DIExpression *Expr,
ArrayRef<uint64_t> Ops) { … }
DIExpression *DIExpression::appendToStack(const DIExpression *Expr,
ArrayRef<uint64_t> Ops) { … }
std::optional<DIExpression *> DIExpression::createFragmentExpression(
const DIExpression *Expr, unsigned OffsetInBits, unsigned SizeInBits) { … }
bool DIExpression::calculateFragmentIntersect(
const DataLayout &DL, const Value *SliceStart, uint64_t SliceOffsetInBits,
uint64_t SliceSizeInBits, const Value *DbgPtr, int64_t DbgPtrOffsetInBits,
int64_t DbgExtractOffsetInBits, DIExpression::FragmentInfo VarFrag,
std::optional<DIExpression::FragmentInfo> &Result,
int64_t &OffsetFromLocationInBits) { … }
std::pair<DIExpression *, const ConstantInt *>
DIExpression::constantFold(const ConstantInt *CI) { … }
uint64_t DIExpression::getNumLocationOperands() const { … }
std::optional<DIExpression::SignedOrUnsignedConstant>
DIExpression::isConstant() const { … }
DIExpression::ExtOps DIExpression::getExtOps(unsigned FromSize, unsigned ToSize,
bool Signed) { … }
DIExpression *DIExpression::appendExt(const DIExpression *Expr,
unsigned FromSize, unsigned ToSize,
bool Signed) { … }
DIGlobalVariableExpression *
DIGlobalVariableExpression::getImpl(LLVMContext &Context, Metadata *Variable,
Metadata *Expression, StorageType Storage,
bool ShouldCreate) { … }
DIObjCProperty::DIObjCProperty(LLVMContext &C, StorageType Storage,
unsigned Line, unsigned Attributes,
ArrayRef<Metadata *> Ops)
: … { … }
DIObjCProperty *DIObjCProperty::getImpl(
LLVMContext &Context, MDString *Name, Metadata *File, unsigned Line,
MDString *GetterName, MDString *SetterName, unsigned Attributes,
Metadata *Type, StorageType Storage, bool ShouldCreate) { … }
DIImportedEntity *DIImportedEntity::getImpl(LLVMContext &Context, unsigned Tag,
Metadata *Scope, Metadata *Entity,
Metadata *File, unsigned Line,
MDString *Name, Metadata *Elements,
StorageType Storage,
bool ShouldCreate) { … }
DIMacro *DIMacro::getImpl(LLVMContext &Context, unsigned MIType, unsigned Line,
MDString *Name, MDString *Value, StorageType Storage,
bool ShouldCreate) { … }
DIMacroFile *DIMacroFile::getImpl(LLVMContext &Context, unsigned MIType,
unsigned Line, Metadata *File,
Metadata *Elements, StorageType Storage,
bool ShouldCreate) { … }
DIArgList *DIArgList::get(LLVMContext &Context,
ArrayRef<ValueAsMetadata *> Args) { … }
void DIArgList::handleChangedOperand(void *Ref, Metadata *New) { … }
void DIArgList::track() { … }
void DIArgList::untrack() { … }
void DIArgList::dropAllReferences(bool Untrack) { … }