LLVM 20.0.0git
Macros | Functions | Variables
DebugInfo.cpp File Reference
#include "llvm-c/DebugInfo.h"
#include "LLVMContextImpl.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DebugLoc.h"
#include "llvm/IR/DebugProgramInstruction.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GVMaterializer.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PassManager.h"
#include "llvm/Support/Casting.h"
#include <algorithm>
#include <cassert>
#include <optional>
#include <utility>
#include "llvm/BinaryFormat/Dwarf.def"
#include "llvm/IR/Metadata.def"

Go to the source code of this file.

Macros

#define HANDLE_DW_LANG(ID, NAME, LOWER_BOUND, VERSION, VENDOR)
 
#define HANDLE_METADATA_LEAF(CLASS)
 
#define DEBUG_TYPE   "assignment-tracking"
 

Functions

template<typename IntrinsicT , bool DbgAssignAndValuesOnly>
static void findDbgIntrinsics (SmallVectorImpl< IntrinsicT * > &Result, Value *V, SmallVectorImpl< DbgVariableRecord * > *DbgVariableRecords)
 
static MDNodeupdateLoopMetadataDebugLocationsImpl (MDNode *OrigLoopID, function_ref< Metadata *(Metadata *)> Updater)
 
static bool isDILocationReachable (SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &Reachable, Metadata *MD)
 Return true if a node is a DILocation or if a DILocation is indirectly referenced by one of the node's children.
 
static bool isAllDILocation (SmallPtrSetImpl< Metadata * > &Visited, SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
 
static MetadatastripLoopMDLoc (const SmallPtrSetImpl< Metadata * > &AllDILocation, const SmallPtrSetImpl< Metadata * > &DIReachable, Metadata *MD)
 
static MDNodestripDebugLocFromLoopID (MDNode *N)
 
static unsigned map_from_llvmDWARFsourcelanguage (LLVMDWARFSourceLanguage lang)
 
template<typename DIT >
DIT * unwrapDI (LLVMMetadataRef Ref)
 
static DINode::DIFlags map_from_llvmDIFlags (LLVMDIFlags Flags)
 
static LLVMDIFlags map_to_llvmDIFlags (DINode::DIFlags Flags)
 
static DISubprogram::DISPFlags pack_into_DISPFlags (bool IsLocalToUnit, bool IsDefinition, bool IsOptimized)
 
unsigned LLVMDebugMetadataVersion ()
 The current debug metadata version number.
 
LLVMDIBuilderRef LLVMCreateDIBuilderDisallowUnresolved (LLVMModuleRef M)
 Construct a builder for a module, and do not allow for unresolved nodes attached to the module.
 
LLVMDIBuilderRef LLVMCreateDIBuilder (LLVMModuleRef M)
 Construct a builder for a module and collect unresolved nodes attached to the module in order to resolve cycles during a call to LLVMDIBuilderFinalize.
 
unsigned LLVMGetModuleDebugMetadataVersion (LLVMModuleRef M)
 The version of debug metadata that's present in the provided Module.
 
LLVMBool LLVMStripModuleDebugInfo (LLVMModuleRef M)
 Strip debug info in the module if it exists.
 
void LLVMDisposeDIBuilder (LLVMDIBuilderRef Builder)
 Deallocates the DIBuilder and everything it owns.
 
void LLVMDIBuilderFinalize (LLVMDIBuilderRef Builder)
 Construct any deferred debug info descriptors.
 
void LLVMDIBuilderFinalizeSubprogram (LLVMDIBuilderRef Builder, LLVMMetadataRef subprogram)
 Finalize a specific subprogram.
 
LLVMMetadataRef LLVMDIBuilderCreateCompileUnit (LLVMDIBuilderRef Builder, LLVMDWARFSourceLanguage Lang, LLVMMetadataRef FileRef, const char *Producer, size_t ProducerLen, LLVMBool isOptimized, const char *Flags, size_t FlagsLen, unsigned RuntimeVer, const char *SplitName, size_t SplitNameLen, LLVMDWARFEmissionKind Kind, unsigned DWOId, LLVMBool SplitDebugInlining, LLVMBool DebugInfoForProfiling, const char *SysRoot, size_t SysRootLen, const char *SDK, size_t SDKLen)
 A CompileUnit provides an anchor for all debugging information generated during this instance of compilation.
 
LLVMMetadataRef LLVMDIBuilderCreateFile (LLVMDIBuilderRef Builder, const char *Filename, size_t FilenameLen, const char *Directory, size_t DirectoryLen)
 Create a file descriptor to hold debugging information for a file.
 
LLVMMetadataRef LLVMDIBuilderCreateModule (LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, const char *ConfigMacros, size_t ConfigMacrosLen, const char *IncludePath, size_t IncludePathLen, const char *APINotesFile, size_t APINotesFileLen)
 Creates a new descriptor for a module with the specified parent scope.
 
LLVMMetadataRef LLVMDIBuilderCreateNameSpace (LLVMDIBuilderRef Builder, LLVMMetadataRef ParentScope, const char *Name, size_t NameLen, LLVMBool ExportSymbols)
 Creates a new descriptor for a namespace with the specified parent scope.
 
LLVMMetadataRef LLVMDIBuilderCreateFunction (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *LinkageName, size_t LinkageNameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool IsLocalToUnit, LLVMBool IsDefinition, unsigned ScopeLine, LLVMDIFlags Flags, LLVMBool IsOptimized)
 Create a new descriptor for the specified subprogram.
 
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlock (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned Col)
 Create a descriptor for a lexical block with the specified parent context.
 
LLVMMetadataRef LLVMDIBuilderCreateLexicalBlockFile (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Discriminator)
 Create a descriptor for a lexical block with a new file attached.
 
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromNamespace (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef NS, LLVMMetadataRef File, unsigned Line)
 Create a descriptor for an imported namespace.
 
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromAlias (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef ImportedEntity, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
 Create a descriptor for an imported module that aliases another imported entity descriptor.
 
LLVMMetadataRef LLVMDIBuilderCreateImportedModuleFromModule (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef M, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef *Elements, unsigned NumElements)
 Create a descriptor for an imported module.
 
LLVMMetadataRef LLVMDIBuilderCreateImportedDeclaration (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, LLVMMetadataRef Decl, LLVMMetadataRef File, unsigned Line, const char *Name, size_t NameLen, LLVMMetadataRef *Elements, unsigned NumElements)
 Create a descriptor for an imported function, type, or variable.
 
LLVMMetadataRef LLVMDIBuilderCreateDebugLocation (LLVMContextRef Ctx, unsigned Line, unsigned Column, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt)
 Creates a new DebugLocation that describes a source location.
 
unsigned LLVMDILocationGetLine (LLVMMetadataRef Location)
 Get the line number of this debug location.
 
unsigned LLVMDILocationGetColumn (LLVMMetadataRef Location)
 Get the column number of this debug location.
 
LLVMMetadataRef LLVMDILocationGetScope (LLVMMetadataRef Location)
 Get the local scope associated with this debug location.
 
LLVMMetadataRef LLVMDILocationGetInlinedAt (LLVMMetadataRef Location)
 Get the "inline at" location associated with this debug location.
 
LLVMMetadataRef LLVMDIScopeGetFile (LLVMMetadataRef Scope)
 Get the metadata of the file associated with a given scope.
 
const charLLVMDIFileGetDirectory (LLVMMetadataRef File, unsigned *Len)
 Get the directory of a given file.
 
const charLLVMDIFileGetFilename (LLVMMetadataRef File, unsigned *Len)
 Get the name of a given file.
 
const charLLVMDIFileGetSource (LLVMMetadataRef File, unsigned *Len)
 Get the source of a given file.
 
LLVMMetadataRef LLVMDIBuilderCreateMacro (LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMDWARFMacinfoRecordType RecordType, const char *Name, size_t NameLen, const char *Value, size_t ValueLen)
 Create debugging information entry for a macro.
 
LLVMMetadataRef LLVMDIBuilderCreateTempMacroFile (LLVMDIBuilderRef Builder, LLVMMetadataRef ParentMacroFile, unsigned Line, LLVMMetadataRef File)
 Create debugging information temporary entry for a macro file.
 
LLVMMetadataRef LLVMDIBuilderCreateEnumerator (LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, int64_t Value, LLVMBool IsUnsigned)
 Create debugging information entry for an enumerator.
 
LLVMMetadataRef LLVMDIBuilderCreateEnumerationType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef ClassTy)
 Create debugging information entry for an enumeration.
 
LLVMMetadataRef LLVMDIBuilderCreateUnionType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, const char *UniqueId, size_t UniqueIdLen)
 Create debugging information entry for a union.
 
LLVMMetadataRef LLVMDIBuilderCreateArrayType (LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
 Create debugging information entry for an array.
 
LLVMMetadataRef LLVMDIBuilderCreateVectorType (LLVMDIBuilderRef Builder, uint64_t Size, uint32_t AlignInBits, LLVMMetadataRef Ty, LLVMMetadataRef *Subscripts, unsigned NumSubscripts)
 Create debugging information entry for a vector type.
 
LLVMMetadataRef LLVMDIBuilderCreateBasicType (LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, uint64_t SizeInBits, LLVMDWARFTypeEncoding Encoding, LLVMDIFlags Flags)
 Create debugging information entry for a basic type.
 
LLVMMetadataRef LLVMDIBuilderCreatePointerType (LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeTy, uint64_t SizeInBits, uint32_t AlignInBits, unsigned AddressSpace, const char *Name, size_t NameLen)
 Create debugging information entry for a pointer.
 
LLVMMetadataRef LLVMDIBuilderCreateStructType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, unsigned RunTimeLang, LLVMMetadataRef VTableHolder, const char *UniqueId, size_t UniqueIdLen)
 Create debugging information entry for a struct.
 
LLVMMetadataRef LLVMDIBuilderCreateMemberType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty)
 Create debugging information entry for a member.
 
LLVMMetadataRef LLVMDIBuilderCreateUnspecifiedType (LLVMDIBuilderRef Builder, const char *Name, size_t NameLen)
 Create a DWARF unspecified type.
 
LLVMMetadataRef LLVMDIBuilderCreateStaticMemberType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, LLVMMetadataRef Type, LLVMDIFlags Flags, LLVMValueRef ConstantVal, uint32_t AlignInBits)
 Create debugging information entry for a C++ static data member.
 
LLVMMetadataRef LLVMDIBuilderCreateObjCIVar (LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Ty, LLVMMetadataRef PropertyNode)
 Create debugging information entry for Objective-C instance variable.
 
LLVMMetadataRef LLVMDIBuilderCreateObjCProperty (LLVMDIBuilderRef Builder, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, const char *GetterName, size_t GetterNameLen, const char *SetterName, size_t SetterNameLen, unsigned PropertyAttributes, LLVMMetadataRef Ty)
 Create debugging information entry for Objective-C property.
 
LLVMMetadataRef LLVMDIBuilderCreateObjectPointerType (LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
 Create a uniqued DIType* clone with FlagObjectPointer and FlagArtificial set.
 
LLVMMetadataRef LLVMDIBuilderCreateTypedef (LLVMDIBuilderRef Builder, LLVMMetadataRef Type, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Scope, uint32_t AlignInBits)
 Create debugging information entry for a typedef.
 
LLVMMetadataRef LLVMDIBuilderCreateInheritance (LLVMDIBuilderRef Builder, LLVMMetadataRef Ty, LLVMMetadataRef BaseTy, uint64_t BaseOffset, uint32_t VBPtrOffset, LLVMDIFlags Flags)
 Create debugging information entry to establish inheritance relationship between two types.
 
LLVMMetadataRef LLVMDIBuilderCreateForwardDecl (LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
 Create a permanent forward-declared type.
 
LLVMMetadataRef LLVMDIBuilderCreateReplaceableCompositeType (LLVMDIBuilderRef Builder, unsigned Tag, const char *Name, size_t NameLen, LLVMMetadataRef Scope, LLVMMetadataRef File, unsigned Line, unsigned RuntimeLang, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
 Create a temporary forward-declared type.
 
LLVMMetadataRef LLVMDIBuilderCreateQualifiedType (LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
 Create debugging information entry for a qualified type, e.g.
 
LLVMMetadataRef LLVMDIBuilderCreateReferenceType (LLVMDIBuilderRef Builder, unsigned Tag, LLVMMetadataRef Type)
 Create debugging information entry for a c++ style reference or rvalue reference type.
 
LLVMMetadataRef LLVMDIBuilderCreateNullPtrType (LLVMDIBuilderRef Builder)
 Create C++11 nullptr type.
 
LLVMMetadataRef LLVMDIBuilderCreateMemberPointerType (LLVMDIBuilderRef Builder, LLVMMetadataRef PointeeType, LLVMMetadataRef ClassType, uint64_t SizeInBits, uint32_t AlignInBits, LLVMDIFlags Flags)
 Create debugging information entry for a pointer to member.
 
LLVMMetadataRef LLVMDIBuilderCreateBitFieldMemberType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint64_t OffsetInBits, uint64_t StorageOffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef Type)
 Create debugging information entry for a bit field member.
 
LLVMMetadataRef LLVMDIBuilderCreateClassType (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNumber, uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits, LLVMDIFlags Flags, LLVMMetadataRef DerivedFrom, LLVMMetadataRef *Elements, unsigned NumElements, LLVMMetadataRef VTableHolder, LLVMMetadataRef TemplateParamsNode, const char *UniqueIdentifier, size_t UniqueIdentifierLen)
 Create debugging information entry for a class.
 
LLVMMetadataRef LLVMDIBuilderCreateArtificialType (LLVMDIBuilderRef Builder, LLVMMetadataRef Type)
 Create a uniqued DIType* clone with FlagArtificial set.
 
uint16_t LLVMGetDINodeTag (LLVMMetadataRef MD)
 Get the dwarf::Tag of a DINode.
 
const charLLVMDITypeGetName (LLVMMetadataRef DType, size_t *Length)
 Get the name of this DIType.
 
uint64_t LLVMDITypeGetSizeInBits (LLVMMetadataRef DType)
 Get the size of this DIType in bits.
 
uint64_t LLVMDITypeGetOffsetInBits (LLVMMetadataRef DType)
 Get the offset of this DIType in bits.
 
uint32_t LLVMDITypeGetAlignInBits (LLVMMetadataRef DType)
 Get the alignment of this DIType in bits.
 
unsigned LLVMDITypeGetLine (LLVMMetadataRef DType)
 Get the source line where this DIType is declared.
 
LLVMDIFlags LLVMDITypeGetFlags (LLVMMetadataRef DType)
 Get the flags associated with this DIType.
 
LLVMMetadataRef LLVMDIBuilderGetOrCreateTypeArray (LLVMDIBuilderRef Builder, LLVMMetadataRef *Types, size_t Length)
 Create a type array.
 
LLVMMetadataRef LLVMDIBuilderCreateSubroutineType (LLVMDIBuilderRef Builder, LLVMMetadataRef File, LLVMMetadataRef *ParameterTypes, unsigned NumParameterTypes, LLVMDIFlags Flags)
 Create subroutine type.
 
LLVMMetadataRef LLVMDIBuilderCreateExpression (LLVMDIBuilderRef Builder, uint64_t *Addr, size_t Length)
 Create a new descriptor for the specified variable which has a complex address expression for its address.
 
LLVMMetadataRef LLVMDIBuilderCreateConstantValueExpression (LLVMDIBuilderRef Builder, uint64_t Value)
 Create a new descriptor for the specified variable that does not have an address, but does have a constant value.
 
LLVMMetadataRef LLVMDIBuilderCreateGlobalVariableExpression (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LinkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Expr, LLVMMetadataRef Decl, uint32_t AlignInBits)
 Create a new descriptor for the specified variable.
 
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetVariable (LLVMMetadataRef GVE)
 Retrieves the DIVariable associated with this global variable expression.
 
LLVMMetadataRef LLVMDIGlobalVariableExpressionGetExpression (LLVMMetadataRef GVE)
 Retrieves the DIExpression associated with this global variable expression.
 
LLVMMetadataRef LLVMDIVariableGetFile (LLVMMetadataRef Var)
 Get the metadata of the file associated with a given variable.
 
LLVMMetadataRef LLVMDIVariableGetScope (LLVMMetadataRef Var)
 Get the metadata of the scope associated with a given variable.
 
unsigned LLVMDIVariableGetLine (LLVMMetadataRef Var)
 Get the source line where this DIVariable is declared.
 
LLVMMetadataRef LLVMTemporaryMDNode (LLVMContextRef Ctx, LLVMMetadataRef *Data, size_t Count)
 Create a new temporary MDNode.
 
void LLVMDisposeTemporaryMDNode (LLVMMetadataRef TempNode)
 Deallocate a temporary node.
 
void LLVMMetadataReplaceAllUsesWith (LLVMMetadataRef TargetMetadata, LLVMMetadataRef Replacement)
 Replace all uses of temporary metadata.
 
LLVMMetadataRef LLVMDIBuilderCreateTempGlobalVariableFwdDecl (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, const char *Linkage, size_t LnkLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool LocalToUnit, LLVMMetadataRef Decl, uint32_t AlignInBits)
 Create a new descriptor for the specified global variable that is temporary and meant to be RAUWed.
 
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordBefore (LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMValueRef Instr)
 Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
 
LLVMDbgRecordRef LLVMDIBuilderInsertDeclareRecordAtEnd (LLVMDIBuilderRef Builder, LLVMValueRef Storage, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DL, LLVMBasicBlockRef Block)
 Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
 
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordBefore (LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMValueRef Instr)
 Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
 
LLVMDbgRecordRef LLVMDIBuilderInsertDbgValueRecordAtEnd (LLVMDIBuilderRef Builder, LLVMValueRef Val, LLVMMetadataRef VarInfo, LLVMMetadataRef Expr, LLVMMetadataRef DebugLoc, LLVMBasicBlockRef Block)
 Only use in "new debug format" (LLVMIsNewDbgInfoFormat() is true).
 
LLVMMetadataRef LLVMDIBuilderCreateAutoVariable (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags, uint32_t AlignInBits)
 Create a new descriptor for a local auto variable.
 
LLVMMetadataRef LLVMDIBuilderCreateParameterVariable (LLVMDIBuilderRef Builder, LLVMMetadataRef Scope, const char *Name, size_t NameLen, unsigned ArgNo, LLVMMetadataRef File, unsigned LineNo, LLVMMetadataRef Ty, LLVMBool AlwaysPreserve, LLVMDIFlags Flags)
 Create a new descriptor for a function parameter variable.
 
LLVMMetadataRef LLVMDIBuilderGetOrCreateSubrange (LLVMDIBuilderRef Builder, int64_t Lo, int64_t Count)
 Create a descriptor for a value range.
 
LLVMMetadataRef LLVMDIBuilderGetOrCreateArray (LLVMDIBuilderRef Builder, LLVMMetadataRef *Data, size_t Length)
 Create an array of DI Nodes.
 
LLVMMetadataRef LLVMGetSubprogram (LLVMValueRef Func)
 Get the metadata of the subprogram attached to a function.
 
void LLVMSetSubprogram (LLVMValueRef Func, LLVMMetadataRef SP)
 Set the subprogram attached to a function.
 
unsigned LLVMDISubprogramGetLine (LLVMMetadataRef Subprogram)
 Get the line associated with a given subprogram.
 
LLVMMetadataRef LLVMInstructionGetDebugLoc (LLVMValueRef Inst)
 Get the debug location for the given instruction.
 
void LLVMInstructionSetDebugLoc (LLVMValueRef Inst, LLVMMetadataRef Loc)
 Set the debug location for the given instruction.
 
LLVMMetadataRef LLVMDIBuilderCreateLabel (LLVMDIBuilderRef Builder, LLVMMetadataRef Context, const char *Name, size_t NameLen, LLVMMetadataRef File, unsigned LineNo, LLVMBool AlwaysPreserve)
 Create a new descriptor for a label.
 
LLVMDbgRecordRef LLVMDIBuilderInsertLabelBefore (LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMValueRef InsertBefore)
 Insert a new llvm.dbg.label intrinsic call.
 
LLVMDbgRecordRef LLVMDIBuilderInsertLabelAtEnd (LLVMDIBuilderRef Builder, LLVMMetadataRef LabelInfo, LLVMMetadataRef Location, LLVMBasicBlockRef InsertAtEnd)
 Insert a new llvm.dbg.label intrinsic call.
 
LLVMMetadataKind LLVMGetMetadataKind (LLVMMetadataRef Metadata)
 Obtain the enumerated type of a Metadata instance.
 
template<typename T >
bool calculateFragmentIntersectImpl (const DataLayout &DL, const Value *Dest, uint64_t SliceOffsetInBits, uint64_t SliceSizeInBits, const T *AssignRecord, std::optional< DIExpression::FragmentInfo > &Result)
 FIXME: Remove this wrapper function and call DIExpression::calculateFragmentIntersect directly.
 
static std::optional< AssignmentInfogetAssignmentInfoImpl (const DataLayout &DL, const Value *StoreDest, TypeSize SizeInBits)
 Collect constant properies (base, size, offset) of StoreDest.
 
static void emitDbgAssign (AssignmentInfo Info, Value *Val, Value *Dest, Instruction &StoreLikeInst, const VarRecord &VarRec, DIBuilder &DIB)
 Returns nullptr if the assignment shouldn't be attributed to this variable.
 
static void setAssignmentTrackingModuleFlag (Module &M)
 
static bool getAssignmentTrackingModuleFlag (const Module &M)
 

Variables

static const charAssignmentTrackingModuleFlag
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "assignment-tracking"

Definition at line 2110 of file DebugInfo.cpp.

◆ HANDLE_DW_LANG

#define HANDLE_DW_LANG (   ID,
  NAME,
  LOWER_BOUND,
  VERSION,
  VENDOR 
)
Value:
return ID;
LLVMDWARFSourceLanguage
Source languages known by DWARF.
Definition: DebugInfo.h:78
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24

◆ HANDLE_METADATA_LEAF

#define HANDLE_METADATA_LEAF (   CLASS)
Value:
case Metadata::CLASS##Kind: \
return (LLVMMetadataKind)LLVM##CLASS##MetadataKind;
unsigned LLVMMetadataKind
Definition: DebugInfo.h:199

Function Documentation

◆ calculateFragmentIntersectImpl()

template<typename T >
bool calculateFragmentIntersectImpl ( const DataLayout DL,
const Value Dest,
uint64_t  SliceOffsetInBits,
uint64_t  SliceSizeInBits,
const T AssignRecord,
std::optional< DIExpression::FragmentInfo > &  Result 
)

FIXME: Remove this wrapper function and call DIExpression::calculateFragmentIntersect directly.

Definition at line 1928 of file DebugInfo.cpp.

References Addr, llvm::DIExpression::calculateFragmentIntersect(), and DL.

Referenced by llvm::at::calculateFragmentIntersect().

◆ emitDbgAssign()

static void emitDbgAssign ( AssignmentInfo  Info,
Value Val,
Value Dest,
Instruction StoreLikeInst,
const VarRecord VarRec,
DIBuilder DIB 
)
static

◆ findDbgIntrinsics()

template<typename IntrinsicT , bool DbgAssignAndValuesOnly>
static void findDbgIntrinsics ( SmallVectorImpl< IntrinsicT * > &  Result,
Value V,
SmallVectorImpl< DbgVariableRecord * > *  DbgVariableRecords 
)
static

◆ getAssignmentInfoImpl()

static std::optional< AssignmentInfo > getAssignmentInfoImpl ( const DataLayout DL,
const Value StoreDest,
TypeSize  SizeInBits 
)
static

Collect constant properies (base, size, offset) of StoreDest.

Return std::nullopt if any properties are not constants or the offset from the base pointer is negative.

Definition at line 2007 of file DebugInfo.cpp.

References llvm::sampleprof::Base, DL, llvm::APInt::getLimitedValue(), llvm::Value::getType(), llvm::APInt::isNegative(), llvm::details::FixedOrScalableQuantity< LeafTy, ValueTy >::isScalable(), llvm::Value::stripAndAccumulateConstantOffsets(), and UINT64_MAX.

Referenced by llvm::at::getAssignmentInfo().

◆ getAssignmentTrackingModuleFlag()

static bool getAssignmentTrackingModuleFlag ( const Module M)
static

Definition at line 2293 of file DebugInfo.cpp.

References AssignmentTrackingModuleFlag.

Referenced by llvm::isAssignmentTrackingEnabled().

◆ isAllDILocation()

static bool isAllDILocation ( SmallPtrSetImpl< Metadata * > &  Visited,
SmallPtrSetImpl< Metadata * > &  AllDILocation,
const SmallPtrSetImpl< Metadata * > &  DIReachable,
Metadata MD 
)
static

◆ isDILocationReachable()

static bool isDILocationReachable ( SmallPtrSetImpl< Metadata * > &  Visited,
SmallPtrSetImpl< Metadata * > &  Reachable,
Metadata MD 
)
static

Return true if a node is a DILocation or if a DILocation is indirectly referenced by one of the node's children.

Definition at line 450 of file DebugInfo.cpp.

References llvm::SmallPtrSetImpl< PtrType >::count(), llvm::SmallPtrSetImpl< PtrType >::insert(), isDILocationReachable(), and N.

Referenced by isDILocationReachable().

◆ map_from_llvmDIFlags()

static DINode::DIFlags map_from_llvmDIFlags ( LLVMDIFlags  Flags)
static

◆ map_from_llvmDWARFsourcelanguage()

static unsigned map_from_llvmDWARFsourcelanguage ( LLVMDWARFSourceLanguage  lang)
static

Definition at line 1025 of file DebugInfo.cpp.

References llvm_unreachable.

Referenced by LLVMDIBuilderCreateCompileUnit().

◆ map_to_llvmDIFlags()

static LLVMDIFlags map_to_llvmDIFlags ( DINode::DIFlags  Flags)
static

Definition at line 1044 of file DebugInfo.cpp.

Referenced by LLVMDITypeGetFlags().

◆ pack_into_DISPFlags()

static DISubprogram::DISPFlags pack_into_DISPFlags ( bool  IsLocalToUnit,
bool  IsDefinition,
bool  IsOptimized 
)
static

Definition at line 1049 of file DebugInfo.cpp.

References llvm::DISubprogram::toSPFlags().

Referenced by LLVMDIBuilderCreateFunction().

◆ setAssignmentTrackingModuleFlag()

static void setAssignmentTrackingModuleFlag ( Module M)
static

◆ stripDebugLocFromLoopID()

static MDNode * stripDebugLocFromLoopID ( MDNode N)
static

◆ stripLoopMDLoc()

static Metadata * stripLoopMDLoc ( const SmallPtrSetImpl< Metadata * > &  AllDILocation,
const SmallPtrSetImpl< Metadata * > &  DIReachable,
Metadata MD 
)
static

◆ unwrapDI()

template<typename DIT >
DIT * unwrapDI ( LLVMMetadataRef  Ref)

Definition at line 1036 of file DebugInfo.cpp.

References llvm::Ref.

◆ updateLoopMetadataDebugLocationsImpl()

static MDNode * updateLoopMetadataDebugLocationsImpl ( MDNode OrigLoopID,
function_ref< Metadata *(Metadata *)>  Updater 
)
static

Variable Documentation

◆ AssignmentTrackingModuleFlag

const char* AssignmentTrackingModuleFlag
static
Initial value:
=
"debug-info-assignment-tracking"

Definition at line 2284 of file DebugInfo.cpp.

Referenced by getAssignmentTrackingModuleFlag(), and setAssignmentTrackingModuleFlag().