Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:44:00

0001 //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 //
0009 // This file defines a DIBuilder that is useful for creating debugging
0010 // information entries in LLVM IR form.
0011 //
0012 //===----------------------------------------------------------------------===//
0013 
0014 #ifndef LLVM_IR_DIBUILDER_H
0015 #define LLVM_IR_DIBUILDER_H
0016 
0017 #include "llvm/ADT/ArrayRef.h"
0018 #include "llvm/ADT/DenseMap.h"
0019 #include "llvm/ADT/MapVector.h"
0020 #include "llvm/ADT/SetVector.h"
0021 #include "llvm/ADT/SmallVector.h"
0022 #include "llvm/ADT/StringRef.h"
0023 #include "llvm/BinaryFormat/Dwarf.h"
0024 #include "llvm/IR/DebugInfoMetadata.h"
0025 #include "llvm/IR/TrackingMDRef.h"
0026 #include "llvm/Support/Casting.h"
0027 #include <algorithm>
0028 #include <cstdint>
0029 #include <optional>
0030 
0031 namespace llvm {
0032 
0033   class BasicBlock;
0034   class Constant;
0035   class Function;
0036   class Instruction;
0037   class LLVMContext;
0038   class Module;
0039   class Value;
0040   class DbgAssignIntrinsic;
0041   class DbgRecord;
0042 
0043   using DbgInstPtr = PointerUnion<Instruction *, DbgRecord *>;
0044 
0045   class DIBuilder {
0046     Module &M;
0047     LLVMContext &VMContext;
0048 
0049     DICompileUnit *CUNode;   ///< The one compile unit created by this DIBuiler.
0050     Function *DeclareFn;     ///< llvm.dbg.declare
0051     Function *ValueFn;       ///< llvm.dbg.value
0052     Function *LabelFn;       ///< llvm.dbg.label
0053     Function *AssignFn;      ///< llvm.dbg.assign
0054 
0055     SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
0056     /// Track the RetainTypes, since they can be updated later on.
0057     SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
0058     SmallVector<DISubprogram *, 4> AllSubprograms;
0059     SmallVector<Metadata *, 4> AllGVs;
0060     SmallVector<TrackingMDNodeRef, 4> ImportedModules;
0061     /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of
0062     /// Metadata all of type DIMacroNode.
0063     /// DIMacroNode's with nullptr parent are DICompileUnit direct children.
0064     MapVector<MDNode *, SetVector<Metadata *>> AllMacrosPerParent;
0065 
0066     /// Track nodes that may be unresolved.
0067     SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
0068     bool AllowUnresolvedNodes;
0069 
0070     /// Each subprogram's preserved local variables, labels and imported
0071     /// entities.
0072     ///
0073     /// Do not use a std::vector.  Some versions of libc++ apparently copy
0074     /// instead of move on grow operations, and TrackingMDRef is expensive to
0075     /// copy.
0076     DenseMap<DISubprogram *, SmallVector<TrackingMDNodeRef, 4>>
0077         SubprogramTrackedNodes;
0078 
0079     SmallVectorImpl<TrackingMDNodeRef> &
0080     getImportTrackingVector(const DIScope *S) {
0081       return isa_and_nonnull<DILocalScope>(S)
0082                  ? getSubprogramNodesTrackingVector(S)
0083                  : ImportedModules;
0084     }
0085     SmallVectorImpl<TrackingMDNodeRef> &
0086     getSubprogramNodesTrackingVector(const DIScope *S) {
0087       return SubprogramTrackedNodes[cast<DILocalScope>(S)->getSubprogram()];
0088     }
0089 
0090     /// Create a temporary.
0091     ///
0092     /// Create an \a temporary node and track it in \a UnresolvedNodes.
0093     void trackIfUnresolved(MDNode *N);
0094 
0095     /// Internal helper. Track metadata if untracked and insert \p DVR.
0096     void insertDbgVariableRecord(DbgVariableRecord *DVR,
0097                                  InsertPosition InsertPt);
0098 
0099     /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
0100     Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
0101                                     DILocalVariable *VarInfo,
0102                                     DIExpression *Expr, const DILocation *DL,
0103                                     InsertPosition InsertPt);
0104 
0105   public:
0106     /// Construct a builder for a module.
0107     ///
0108     /// If \c AllowUnresolved, collect unresolved nodes attached to the module
0109     /// in order to resolve cycles during \a finalize().
0110     ///
0111     /// If \p CU is given a value other than nullptr, then set \p CUNode to CU.
0112     explicit DIBuilder(Module &M, bool AllowUnresolved = true,
0113                        DICompileUnit *CU = nullptr);
0114     DIBuilder(const DIBuilder &) = delete;
0115     DIBuilder &operator=(const DIBuilder &) = delete;
0116 
0117     /// Construct any deferred debug info descriptors.
0118     void finalize();
0119 
0120     /// Finalize a specific subprogram - no new variables may be added to this
0121     /// subprogram afterwards.
0122     void finalizeSubprogram(DISubprogram *SP);
0123 
0124     /// A CompileUnit provides an anchor for all debugging
0125     /// information generated during this instance of compilation.
0126     /// \param Lang          Source programming language, eg. dwarf::DW_LANG_C99
0127     /// \param File          File info.
0128     /// \param Producer      Identify the producer of debugging information
0129     ///                      and code.  Usually this is a compiler
0130     ///                      version string.
0131     /// \param isOptimized   A boolean flag which indicates whether optimization
0132     ///                      is enabled or not.
0133     /// \param Flags         This string lists command line options. This
0134     ///                      string is directly embedded in debug info
0135     ///                      output which may be used by a tool
0136     ///                      analyzing generated debugging information.
0137     /// \param RV            This indicates runtime version for languages like
0138     ///                      Objective-C.
0139     /// \param SplitName     The name of the file that we'll split debug info
0140     ///                      out into.
0141     /// \param Kind          The kind of debug information to generate.
0142     /// \param DWOId         The DWOId if this is a split skeleton compile unit.
0143     /// \param SplitDebugInlining    Whether to emit inline debug info.
0144     /// \param DebugInfoForProfiling Whether to emit extra debug info for
0145     ///                              profile collection.
0146     /// \param NameTableKind  Whether to emit .debug_gnu_pubnames,
0147     ///                      .debug_pubnames, or no pubnames at all.
0148     /// \param SysRoot       The clang system root (value of -isysroot).
0149     /// \param SDK           The SDK name. On Darwin, this is the last component
0150     ///                      of the sysroot.
0151     DICompileUnit *
0152     createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
0153                       bool isOptimized, StringRef Flags, unsigned RV,
0154                       StringRef SplitName = StringRef(),
0155                       DICompileUnit::DebugEmissionKind Kind =
0156                           DICompileUnit::DebugEmissionKind::FullDebug,
0157                       uint64_t DWOId = 0, bool SplitDebugInlining = true,
0158                       bool DebugInfoForProfiling = false,
0159                       DICompileUnit::DebugNameTableKind NameTableKind =
0160                           DICompileUnit::DebugNameTableKind::Default,
0161                       bool RangesBaseAddress = false, StringRef SysRoot = {},
0162                       StringRef SDK = {});
0163 
0164     /// Create a file descriptor to hold debugging information for a file.
0165     /// \param Filename  File name.
0166     /// \param Directory Directory.
0167     /// \param Checksum  Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.)
0168     ///                  and value.
0169     /// \param Source    Optional source text.
0170     DIFile *createFile(
0171         StringRef Filename, StringRef Directory,
0172         std::optional<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt,
0173         std::optional<StringRef> Source = std::nullopt);
0174 
0175     /// Create debugging information entry for a macro.
0176     /// \param Parent     Macro parent (could be nullptr).
0177     /// \param Line       Source line number where the macro is defined.
0178     /// \param MacroType  DW_MACINFO_define or DW_MACINFO_undef.
0179     /// \param Name       Macro name.
0180     /// \param Value      Macro value.
0181     DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType,
0182                          StringRef Name, StringRef Value = StringRef());
0183 
0184     /// Create debugging information temporary entry for a macro file.
0185     /// List of macro node direct children will be calculated by DIBuilder,
0186     /// using the \p Parent relationship.
0187     /// \param Parent     Macro file parent (could be nullptr).
0188     /// \param Line       Source line number where the macro file is included.
0189     /// \param File       File descriptor containing the name of the macro file.
0190     DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line,
0191                                      DIFile *File);
0192 
0193     /// Create a single enumerator value.
0194     DIEnumerator *createEnumerator(StringRef Name, const APSInt &Value);
0195     DIEnumerator *createEnumerator(StringRef Name, uint64_t Val,
0196                                    bool IsUnsigned = false);
0197 
0198     /// Create a DWARF unspecified type.
0199     DIBasicType *createUnspecifiedType(StringRef Name);
0200 
0201     /// Create C++11 nullptr type.
0202     DIBasicType *createNullPtrType();
0203 
0204     /// Create debugging information entry for a basic
0205     /// type.
0206     /// \param Name        Type name.
0207     /// \param SizeInBits  Size of the type.
0208     /// \param Encoding    DWARF encoding code, e.g., dwarf::DW_ATE_float.
0209     /// \param Flags       Optional DWARF attributes, e.g., DW_AT_endianity.
0210     /// \param NumExtraInhabitants The number of extra inhabitants of the type.
0211     /// An extra inhabitant is a bit pattern that does not represent a valid
0212     /// value for instances of a given type. This is used by the Swift language.
0213     DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
0214                                  unsigned Encoding,
0215                                  DINode::DIFlags Flags = DINode::FlagZero,
0216                                  uint32_t NumExtraInhabitants = 0);
0217 
0218     /// Create debugging information entry for a string
0219     /// type.
0220     /// \param Name        Type name.
0221     /// \param SizeInBits  Size of the type.
0222     DIStringType *createStringType(StringRef Name, uint64_t SizeInBits);
0223 
0224     /// Create debugging information entry for Fortran
0225     /// assumed length string type.
0226     /// \param Name            Type name.
0227     /// \param StringLength    String length expressed as DIVariable *.
0228     /// \param StrLocationExp  Optional memory location of the string.
0229     DIStringType *createStringType(StringRef Name, DIVariable *StringLength,
0230                                    DIExpression *StrLocationExp = nullptr);
0231 
0232     /// Create debugging information entry for Fortran
0233     /// assumed length string type.
0234     /// \param Name             Type name.
0235     /// \param StringLengthExp  String length expressed in DIExpression form.
0236     /// \param StrLocationExp   Optional memory location of the string.
0237     DIStringType *createStringType(StringRef Name,
0238                                    DIExpression *StringLengthExp,
0239                                    DIExpression *StrLocationExp = nullptr);
0240 
0241     /// Create debugging information entry for a qualified
0242     /// type, e.g. 'const int'.
0243     /// \param Tag         Tag identifing type, e.g. dwarf::TAG_volatile_type
0244     /// \param FromTy      Base Type.
0245     DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
0246 
0247     /// Create debugging information entry for a pointer.
0248     /// \param PointeeTy         Type pointed by this pointer.
0249     /// \param SizeInBits        Size.
0250     /// \param AlignInBits       Alignment. (optional)
0251     /// \param DWARFAddressSpace DWARF address space. (optional)
0252     /// \param Name              Pointer type name. (optional)
0253     /// \param Annotations       Member annotations.
0254     DIDerivedType *
0255     createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
0256                       uint32_t AlignInBits = 0,
0257                       std::optional<unsigned> DWARFAddressSpace = std::nullopt,
0258                       StringRef Name = "", DINodeArray Annotations = nullptr);
0259 
0260     /// Create a __ptrauth qualifier.
0261     DIDerivedType *createPtrAuthQualifiedType(DIType *FromTy, unsigned Key,
0262                                               bool IsAddressDiscriminated,
0263                                               unsigned ExtraDiscriminator,
0264                                               bool IsaPointer,
0265                                               bool authenticatesNullValues);
0266 
0267     /// Create debugging information entry for a pointer to member.
0268     /// \param PointeeTy Type pointed to by this pointer.
0269     /// \param SizeInBits  Size.
0270     /// \param AlignInBits Alignment. (optional)
0271     /// \param Class Type for which this pointer points to members of.
0272     DIDerivedType *
0273     createMemberPointerType(DIType *PointeeTy, DIType *Class,
0274                             uint64_t SizeInBits, uint32_t AlignInBits = 0,
0275                             DINode::DIFlags Flags = DINode::FlagZero);
0276 
0277     /// Create debugging information entry for a c++
0278     /// style reference or rvalue reference type.
0279     DIDerivedType *createReferenceType(
0280         unsigned Tag, DIType *RTy, uint64_t SizeInBits = 0,
0281         uint32_t AlignInBits = 0,
0282         std::optional<unsigned> DWARFAddressSpace = std::nullopt);
0283 
0284     /// Create debugging information entry for a typedef.
0285     /// \param Ty          Original type.
0286     /// \param Name        Typedef name.
0287     /// \param File        File where this type is defined.
0288     /// \param LineNo      Line number.
0289     /// \param Context     The surrounding context for the typedef.
0290     /// \param AlignInBits Alignment. (optional)
0291     /// \param Flags       Flags to describe inheritance attribute, e.g. private
0292     /// \param Annotations Annotations. (optional)
0293     DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
0294                                  unsigned LineNo, DIScope *Context,
0295                                  uint32_t AlignInBits = 0,
0296                                  DINode::DIFlags Flags = DINode::FlagZero,
0297                                  DINodeArray Annotations = nullptr);
0298 
0299     /// Create debugging information entry for a template alias.
0300     /// \param Ty          Original type.
0301     /// \param Name        Alias name.
0302     /// \param File        File where this type is defined.
0303     /// \param LineNo      Line number.
0304     /// \param Context     The surrounding context for the alias.
0305     /// \param TParams     The template arguments.
0306     /// \param AlignInBits Alignment. (optional)
0307     /// \param Flags       Flags to describe inheritance attribute (optional),
0308     ///                    e.g. private.
0309     /// \param Annotations Annotations. (optional)
0310     DIDerivedType *createTemplateAlias(DIType *Ty, StringRef Name, DIFile *File,
0311                                        unsigned LineNo, DIScope *Context,
0312                                        DINodeArray TParams,
0313                                        uint32_t AlignInBits = 0,
0314                                        DINode::DIFlags Flags = DINode::FlagZero,
0315                                        DINodeArray Annotations = nullptr);
0316 
0317     /// Create debugging information entry for a 'friend'.
0318     DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
0319 
0320     /// Create debugging information entry to establish
0321     /// inheritance relationship between two types.
0322     /// \param Ty           Original type.
0323     /// \param BaseTy       Base type. Ty is inherits from base.
0324     /// \param BaseOffset   Base offset.
0325     /// \param VBPtrOffset  Virtual base pointer offset.
0326     /// \param Flags        Flags to describe inheritance attribute,
0327     ///                     e.g. private
0328     DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
0329                                      uint64_t BaseOffset, uint32_t VBPtrOffset,
0330                                      DINode::DIFlags Flags);
0331 
0332     /// Create debugging information entry for a member.
0333     /// \param Scope        Member scope.
0334     /// \param Name         Member name.
0335     /// \param File         File where this member is defined.
0336     /// \param LineNo       Line number.
0337     /// \param SizeInBits   Member size.
0338     /// \param AlignInBits  Member alignment.
0339     /// \param OffsetInBits Member offset.
0340     /// \param Flags        Flags to encode member attribute, e.g. private
0341     /// \param Ty           Parent type.
0342     /// \param Annotations  Member annotations.
0343     DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
0344                                     DIFile *File, unsigned LineNo,
0345                                     uint64_t SizeInBits, uint32_t AlignInBits,
0346                                     uint64_t OffsetInBits,
0347                                     DINode::DIFlags Flags, DIType *Ty,
0348                                     DINodeArray Annotations = nullptr);
0349 
0350     /// Create debugging information entry for a variant.  A variant
0351     /// normally should be a member of a variant part.
0352     /// \param Scope        Member scope.
0353     /// \param Name         Member name.
0354     /// \param File         File where this member is defined.
0355     /// \param LineNo       Line number.
0356     /// \param SizeInBits   Member size.
0357     /// \param AlignInBits  Member alignment.
0358     /// \param OffsetInBits Member offset.
0359     /// \param Flags        Flags to encode member attribute, e.g. private
0360     /// \param Discriminant The discriminant for this branch; null for
0361     ///                     the default branch
0362     /// \param Ty           Parent type.
0363     DIDerivedType *createVariantMemberType(DIScope *Scope, StringRef Name,
0364                        DIFile *File, unsigned LineNo,
0365                        uint64_t SizeInBits,
0366                        uint32_t AlignInBits,
0367                        uint64_t OffsetInBits,
0368                        Constant *Discriminant,
0369                        DINode::DIFlags Flags, DIType *Ty);
0370 
0371     /// Create debugging information entry for a bit field member.
0372     /// \param Scope               Member scope.
0373     /// \param Name                Member name.
0374     /// \param File                File where this member is defined.
0375     /// \param LineNo              Line number.
0376     /// \param SizeInBits          Member size.
0377     /// \param OffsetInBits        Member offset.
0378     /// \param StorageOffsetInBits Member storage offset.
0379     /// \param Flags               Flags to encode member attribute.
0380     /// \param Ty                  Parent type.
0381     /// \param Annotations         Member annotations.
0382     DIDerivedType *createBitFieldMemberType(DIScope *Scope, StringRef Name,
0383                                             DIFile *File, unsigned LineNo,
0384                                             uint64_t SizeInBits,
0385                                             uint64_t OffsetInBits,
0386                                             uint64_t StorageOffsetInBits,
0387                                             DINode::DIFlags Flags, DIType *Ty,
0388                                             DINodeArray Annotations = nullptr);
0389 
0390     /// Create debugging information entry for a
0391     /// C++ static data member.
0392     /// \param Scope      Member scope.
0393     /// \param Name       Member name.
0394     /// \param File       File where this member is declared.
0395     /// \param LineNo     Line number.
0396     /// \param Ty         Type of the static member.
0397     /// \param Flags      Flags to encode member attribute, e.g. private.
0398     /// \param Val        Const initializer of the member.
0399     /// \param Tag        DWARF tag of the static member.
0400     /// \param AlignInBits  Member alignment.
0401     DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
0402                                           DIFile *File, unsigned LineNo,
0403                                           DIType *Ty, DINode::DIFlags Flags,
0404                                           Constant *Val, unsigned Tag,
0405                                           uint32_t AlignInBits = 0);
0406 
0407     /// Create debugging information entry for Objective-C
0408     /// instance variable.
0409     /// \param Name         Member name.
0410     /// \param File         File where this member is defined.
0411     /// \param LineNo       Line number.
0412     /// \param SizeInBits   Member size.
0413     /// \param AlignInBits  Member alignment.
0414     /// \param OffsetInBits Member offset.
0415     /// \param Flags        Flags to encode member attribute, e.g. private
0416     /// \param Ty           Parent type.
0417     /// \param PropertyNode Property associated with this ivar.
0418     DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
0419                                   uint64_t SizeInBits, uint32_t AlignInBits,
0420                                   uint64_t OffsetInBits, DINode::DIFlags Flags,
0421                                   DIType *Ty, MDNode *PropertyNode);
0422 
0423     /// Create debugging information entry for Objective-C
0424     /// property.
0425     /// \param Name         Property name.
0426     /// \param File         File where this property is defined.
0427     /// \param LineNumber   Line number.
0428     /// \param GetterName   Name of the Objective C property getter selector.
0429     /// \param SetterName   Name of the Objective C property setter selector.
0430     /// \param PropertyAttributes Objective C property attributes.
0431     /// \param Ty           Type.
0432     DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
0433                                        unsigned LineNumber,
0434                                        StringRef GetterName,
0435                                        StringRef SetterName,
0436                                        unsigned PropertyAttributes, DIType *Ty);
0437 
0438     /// Create debugging information entry for a class.
0439     /// \param Scope        Scope in which this class is defined.
0440     /// \param Name         class name.
0441     /// \param File         File where this member is defined.
0442     /// \param LineNumber   Line number.
0443     /// \param SizeInBits   Member size.
0444     /// \param AlignInBits  Member alignment.
0445     /// \param OffsetInBits Member offset.
0446     /// \param Flags        Flags to encode member attribute, e.g. private
0447     /// \param Elements     class members.
0448     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
0449     /// \param VTableHolder Debug info of the base class that contains vtable
0450     ///                     for this type. This is used in
0451     ///                     DW_AT_containing_type. See DWARF documentation
0452     ///                     for more info.
0453     /// \param TemplateParms Template type parameters.
0454     /// \param UniqueIdentifier A unique identifier for the class.
0455     DICompositeType *createClassType(
0456         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
0457         uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
0458         DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
0459         unsigned RunTimeLang = 0, DIType *VTableHolder = nullptr,
0460         MDNode *TemplateParms = nullptr, StringRef UniqueIdentifier = "");
0461 
0462     /// Create debugging information entry for a struct.
0463     /// \param Scope        Scope in which this struct is defined.
0464     /// \param Name         Struct name.
0465     /// \param File         File where this member is defined.
0466     /// \param LineNumber   Line number.
0467     /// \param SizeInBits   Member size.
0468     /// \param AlignInBits  Member alignment.
0469     /// \param Flags        Flags to encode member attribute, e.g. private
0470     /// \param Elements     Struct elements.
0471     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
0472     /// \param UniqueIdentifier A unique identifier for the struct.
0473     /// \param Specification The type that this type completes. This is used by
0474     /// Swift to represent generic types.
0475     /// \param NumExtraInhabitants The number of extra inhabitants of the type.
0476     /// An extra inhabitant is a bit pattern that does not represent a valid
0477     /// value for instances of a given type. This is used by the Swift language.
0478     DICompositeType *createStructType(
0479         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
0480         uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
0481         DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
0482         DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "",
0483         DIType *Specification = nullptr, uint32_t NumExtraInhabitants = 0);
0484 
0485     /// Create debugging information entry for an union.
0486     /// \param Scope        Scope in which this union is defined.
0487     /// \param Name         Union name.
0488     /// \param File         File where this member is defined.
0489     /// \param LineNumber   Line number.
0490     /// \param SizeInBits   Member size.
0491     /// \param AlignInBits  Member alignment.
0492     /// \param Flags        Flags to encode member attribute, e.g. private
0493     /// \param Elements     Union elements.
0494     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
0495     /// \param UniqueIdentifier A unique identifier for the union.
0496     DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
0497                                      DIFile *File, unsigned LineNumber,
0498                                      uint64_t SizeInBits, uint32_t AlignInBits,
0499                                      DINode::DIFlags Flags,
0500                                      DINodeArray Elements,
0501                                      unsigned RunTimeLang = 0,
0502                                      StringRef UniqueIdentifier = "");
0503 
0504     /// Create debugging information entry for a variant part.  A
0505     /// variant part normally has a discriminator (though this is not
0506     /// required) and a number of variant children.
0507     /// \param Scope        Scope in which this union is defined.
0508     /// \param Name         Union name.
0509     /// \param File         File where this member is defined.
0510     /// \param LineNumber   Line number.
0511     /// \param SizeInBits   Member size.
0512     /// \param AlignInBits  Member alignment.
0513     /// \param Flags        Flags to encode member attribute, e.g. private
0514     /// \param Discriminator Discriminant member
0515     /// \param Elements     Variant elements.
0516     /// \param UniqueIdentifier A unique identifier for the union.
0517     DICompositeType *createVariantPart(DIScope *Scope, StringRef Name,
0518                        DIFile *File, unsigned LineNumber,
0519                        uint64_t SizeInBits, uint32_t AlignInBits,
0520                        DINode::DIFlags Flags,
0521                        DIDerivedType *Discriminator,
0522                        DINodeArray Elements,
0523                        StringRef UniqueIdentifier = "");
0524 
0525     /// Create debugging information for template
0526     /// type parameter.
0527     /// \param Scope        Scope in which this type is defined.
0528     /// \param Name         Type parameter name.
0529     /// \param Ty           Parameter type.
0530     /// \param IsDefault    Parameter is default or not
0531     DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope,
0532                                                          StringRef Name,
0533                                                          DIType *Ty,
0534                                                          bool IsDefault);
0535 
0536     /// Create debugging information for template
0537     /// value parameter.
0538     /// \param Scope        Scope in which this type is defined.
0539     /// \param Name         Value parameter name.
0540     /// \param Ty           Parameter type.
0541     /// \param IsDefault    Parameter is default or not
0542     /// \param Val          Constant parameter value.
0543     DITemplateValueParameter *
0544     createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty,
0545                                  bool IsDefault, Constant *Val);
0546 
0547     /// Create debugging information for a template template parameter.
0548     /// \param Scope        Scope in which this type is defined.
0549     /// \param Name         Value parameter name.
0550     /// \param Ty           Parameter type.
0551     /// \param Val          The fully qualified name of the template.
0552     /// \param IsDefault    Parameter is default or not.
0553     DITemplateValueParameter *
0554     createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty,
0555                                     StringRef Val, bool IsDefault = false);
0556 
0557     /// Create debugging information for a template parameter pack.
0558     /// \param Scope        Scope in which this type is defined.
0559     /// \param Name         Value parameter name.
0560     /// \param Ty           Parameter type.
0561     /// \param Val          An array of types in the pack.
0562     DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
0563                                                           StringRef Name,
0564                                                           DIType *Ty,
0565                                                           DINodeArray Val);
0566 
0567     /// Create debugging information entry for an array.
0568     /// \param Size         Array size.
0569     /// \param AlignInBits  Alignment.
0570     /// \param Ty           Element type.
0571     /// \param Subscripts   Subscripts.
0572     /// \param DataLocation The location of the raw data of a descriptor-based
0573     ///                     Fortran array, either a DIExpression* or
0574     ///                     a DIVariable*.
0575     /// \param Associated   The associated attribute of a descriptor-based
0576     ///                     Fortran array, either a DIExpression* or
0577     ///                     a DIVariable*.
0578     /// \param Allocated    The allocated attribute of a descriptor-based
0579     ///                     Fortran array, either a DIExpression* or
0580     ///                     a DIVariable*.
0581     /// \param Rank         The rank attribute of a descriptor-based
0582     ///                     Fortran array, either a DIExpression* or
0583     ///                     a DIVariable*.
0584     DICompositeType *createArrayType(
0585         uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
0586         PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr,
0587         PointerUnion<DIExpression *, DIVariable *> Associated = nullptr,
0588         PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
0589         PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
0590 
0591     /// Create debugging information entry for a vector type.
0592     /// \param Size         Array size.
0593     /// \param AlignInBits  Alignment.
0594     /// \param Ty           Element type.
0595     /// \param Subscripts   Subscripts.
0596     DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits,
0597                                       DIType *Ty, DINodeArray Subscripts);
0598 
0599     /// Create debugging information entry for an
0600     /// enumeration.
0601     /// \param Scope          Scope in which this enumeration is defined.
0602     /// \param Name           Union name.
0603     /// \param File           File where this member is defined.
0604     /// \param LineNumber     Line number.
0605     /// \param SizeInBits     Member size.
0606     /// \param AlignInBits    Member alignment.
0607     /// \param Elements       Enumeration elements.
0608     /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
0609     /// \param RunTimeLang  Optional parameter, Objective-C runtime version.
0610     /// \param UniqueIdentifier A unique identifier for the enum.
0611     /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum
0612     /// class'.
0613     DICompositeType *createEnumerationType(
0614         DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
0615         uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
0616         DIType *UnderlyingType, unsigned RunTimeLang = 0,
0617         StringRef UniqueIdentifier = "", bool IsScoped = false);
0618     /// Create debugging information entry for a set.
0619     /// \param Scope          Scope in which this set is defined.
0620     /// \param Name           Set name.
0621     /// \param File           File where this set is defined.
0622     /// \param LineNo         Line number.
0623     /// \param SizeInBits     Set size.
0624     /// \param AlignInBits    Set alignment.
0625     /// \param Ty             Base type of the set.
0626     DIDerivedType *createSetType(DIScope *Scope, StringRef Name, DIFile *File,
0627                                  unsigned LineNo, uint64_t SizeInBits,
0628                                  uint32_t AlignInBits, DIType *Ty);
0629 
0630     /// Create subroutine type.
0631     /// \param ParameterTypes  An array of subroutine parameter types. This
0632     ///                        includes return type at 0th index.
0633     /// \param Flags           E.g.: LValueReference.
0634     ///                        These flags are used to emit dwarf attributes.
0635     /// \param CC              Calling convention, e.g. dwarf::DW_CC_normal
0636     DISubroutineType *
0637     createSubroutineType(DITypeRefArray ParameterTypes,
0638                          DINode::DIFlags Flags = DINode::FlagZero,
0639                          unsigned CC = 0);
0640 
0641     /// Create a distinct clone of \p SP with FlagArtificial set.
0642     static DISubprogram *createArtificialSubprogram(DISubprogram *SP);
0643 
0644     /// Create a uniqued clone of \p Ty with FlagArtificial set.
0645     static DIType *createArtificialType(DIType *Ty);
0646 
0647     /// Create a uniqued clone of \p Ty with FlagObjectPointer set.
0648     /// If \p Implicit is true, also set FlagArtificial.
0649     static DIType *createObjectPointerType(DIType *Ty, bool Implicit);
0650 
0651     /// Create a permanent forward-declared type.
0652     DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
0653                                        DIScope *Scope, DIFile *F, unsigned Line,
0654                                        unsigned RuntimeLang = 0,
0655                                        uint64_t SizeInBits = 0,
0656                                        uint32_t AlignInBits = 0,
0657                                        StringRef UniqueIdentifier = "");
0658 
0659     /// Create a temporary forward-declared type.
0660     DICompositeType *createReplaceableCompositeType(
0661         unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
0662         unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
0663         uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
0664         StringRef UniqueIdentifier = "", DINodeArray Annotations = nullptr);
0665 
0666     /// Retain DIScope* in a module even if it is not referenced
0667     /// through debug info anchors.
0668     void retainType(DIScope *T);
0669 
0670     /// Create unspecified parameter type
0671     /// for a subroutine type.
0672     DIBasicType *createUnspecifiedParameter();
0673 
0674     /// Get a DINodeArray, create one if required.
0675     DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
0676 
0677     /// Get a DIMacroNodeArray, create one if required.
0678     DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements);
0679 
0680     /// Get a DITypeRefArray, create one if required.
0681     DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
0682 
0683     /// Create a descriptor for a value range.  This
0684     /// implicitly uniques the values returned.
0685     DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
0686     DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode);
0687     DISubrange *getOrCreateSubrange(Metadata *Count, Metadata *LowerBound,
0688                                     Metadata *UpperBound, Metadata *Stride);
0689 
0690     DIGenericSubrange *
0691     getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count,
0692                                DIGenericSubrange::BoundType LowerBound,
0693                                DIGenericSubrange::BoundType UpperBound,
0694                                DIGenericSubrange::BoundType Stride);
0695 
0696     /// Create a new descriptor for the specified variable.
0697     /// \param Context     Variable scope.
0698     /// \param Name        Name of the variable.
0699     /// \param LinkageName Mangled  name of the variable.
0700     /// \param File        File where this variable is defined.
0701     /// \param LineNo      Line number.
0702     /// \param Ty          Variable Type.
0703     /// \param IsLocalToUnit Boolean flag indicate whether this variable is
0704     ///                      externally visible or not.
0705     /// \param Expr        The location of the global relative to the attached
0706     ///                    GlobalVariable.
0707     /// \param Decl        Reference to the corresponding declaration.
0708     /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
0709     ///                    specified)
0710     DIGlobalVariableExpression *createGlobalVariableExpression(
0711         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
0712         unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true,
0713         DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
0714         MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0,
0715         DINodeArray Annotations = nullptr);
0716 
0717     /// Identical to createGlobalVariable
0718     /// except that the resulting DbgNode is temporary and meant to be RAUWed.
0719     DIGlobalVariable *createTempGlobalVariableFwdDecl(
0720         DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
0721         unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr,
0722         MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0);
0723 
0724     /// Create a new descriptor for an auto variable.  This is a local variable
0725     /// that is not a subprogram parameter.
0726     ///
0727     /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
0728     /// leads to a \a DISubprogram.
0729     ///
0730     /// If \c AlwaysPreserve, this variable will be referenced from its
0731     /// containing subprogram, and will survive some optimizations.
0732     DILocalVariable *
0733     createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
0734                        unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
0735                        DINode::DIFlags Flags = DINode::FlagZero,
0736                        uint32_t AlignInBits = 0);
0737 
0738     /// Create a new descriptor for an label.
0739     ///
0740     /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
0741     /// leads to a \a DISubprogram.
0742     DILabel *
0743     createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
0744                 bool AlwaysPreserve = false);
0745 
0746     /// Create a new descriptor for a parameter variable.
0747     ///
0748     /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
0749     /// leads to a \a DISubprogram.
0750     ///
0751     /// \c ArgNo is the index (starting from \c 1) of this variable in the
0752     /// subprogram parameters.  \c ArgNo should not conflict with other
0753     /// parameters of the same subprogram.
0754     ///
0755     /// If \c AlwaysPreserve, this variable will be referenced from its
0756     /// containing subprogram, and will survive some optimizations.
0757     DILocalVariable *
0758     createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
0759                             DIFile *File, unsigned LineNo, DIType *Ty,
0760                             bool AlwaysPreserve = false,
0761                             DINode::DIFlags Flags = DINode::FlagZero,
0762                             DINodeArray Annotations = nullptr);
0763 
0764     /// Create a new descriptor for the specified
0765     /// variable which has a complex address expression for its address.
0766     /// \param Addr        An array of complex address operations.
0767     DIExpression *createExpression(ArrayRef<uint64_t> Addr = {});
0768 
0769     /// Create an expression for a variable that does not have an address, but
0770     /// does have a constant value.
0771     DIExpression *createConstantValueExpression(uint64_t Val) {
0772       return DIExpression::get(
0773           VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
0774     }
0775 
0776     /// Create a new descriptor for the specified subprogram.
0777     /// See comments in DISubprogram* for descriptions of these fields.
0778     /// \param Scope         Function scope.
0779     /// \param Name          Function name.
0780     /// \param LinkageName   Mangled function name.
0781     /// \param File          File where this variable is defined.
0782     /// \param LineNo        Line number.
0783     /// \param Ty            Function type.
0784     /// \param ScopeLine     Set to the beginning of the scope this starts
0785     /// \param Flags         e.g. is this function prototyped or not.
0786     ///                      These flags are used to emit dwarf attributes.
0787     /// \param SPFlags       Additional flags specific to subprograms.
0788     /// \param TParams       Function template parameters.
0789     /// \param ThrownTypes   Exception types this function may throw.
0790     /// \param Annotations   Attribute Annotations.
0791     /// \param TargetFuncName The name of the target function if this is
0792     ///                       a trampoline.
0793     DISubprogram *
0794     createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
0795                    DIFile *File, unsigned LineNo, DISubroutineType *Ty,
0796                    unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero,
0797                    DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
0798                    DITemplateParameterArray TParams = nullptr,
0799                    DISubprogram *Decl = nullptr,
0800                    DITypeArray ThrownTypes = nullptr,
0801                    DINodeArray Annotations = nullptr,
0802                    StringRef TargetFuncName = "");
0803 
0804     /// Identical to createFunction,
0805     /// except that the resulting DbgNode is meant to be RAUWed.
0806     DISubprogram *createTempFunctionFwdDecl(
0807         DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
0808         unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
0809         DINode::DIFlags Flags = DINode::FlagZero,
0810         DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
0811         DITemplateParameterArray TParams = nullptr,
0812         DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
0813 
0814     /// Create a new descriptor for the specified C++ method.
0815     /// See comments in \a DISubprogram* for descriptions of these fields.
0816     /// \param Scope         Function scope.
0817     /// \param Name          Function name.
0818     /// \param LinkageName   Mangled function name.
0819     /// \param File          File where this variable is defined.
0820     /// \param LineNo        Line number.
0821     /// \param Ty            Function type.
0822     /// \param VTableIndex   Index no of this method in virtual table, or -1u if
0823     ///                      unrepresentable.
0824     /// \param ThisAdjustment
0825     ///                      MS ABI-specific adjustment of 'this' that occurs
0826     ///                      in the prologue.
0827     /// \param VTableHolder  Type that holds vtable.
0828     /// \param Flags         e.g. is this function prototyped or not.
0829     ///                      This flags are used to emit dwarf attributes.
0830     /// \param SPFlags       Additional flags specific to subprograms.
0831     /// \param TParams       Function template parameters.
0832     /// \param ThrownTypes   Exception types this function may throw.
0833     DISubprogram *
0834     createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
0835                  DIFile *File, unsigned LineNo, DISubroutineType *Ty,
0836                  unsigned VTableIndex = 0, int ThisAdjustment = 0,
0837                  DIType *VTableHolder = nullptr,
0838                  DINode::DIFlags Flags = DINode::FlagZero,
0839                  DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
0840                  DITemplateParameterArray TParams = nullptr,
0841                  DITypeArray ThrownTypes = nullptr);
0842 
0843     /// Create common block entry for a Fortran common block.
0844     /// \param Scope       Scope of this common block.
0845     /// \param decl        Global variable declaration.
0846     /// \param Name        The name of this common block.
0847     /// \param File        The file this common block is defined.
0848     /// \param LineNo      Line number.
0849     DICommonBlock *createCommonBlock(DIScope *Scope, DIGlobalVariable *decl,
0850                                      StringRef Name, DIFile *File,
0851                                      unsigned LineNo);
0852 
0853     /// This creates new descriptor for a namespace with the specified
0854     /// parent scope.
0855     /// \param Scope       Namespace scope
0856     /// \param Name        Name of this namespace
0857     /// \param ExportSymbols True for C++ inline namespaces.
0858     DINamespace *createNameSpace(DIScope *Scope, StringRef Name,
0859                                  bool ExportSymbols);
0860 
0861     /// This creates new descriptor for a module with the specified
0862     /// parent scope.
0863     /// \param Scope       Parent scope
0864     /// \param Name        Name of this module
0865     /// \param ConfigurationMacros
0866     ///                    A space-separated shell-quoted list of -D macro
0867     ///                    definitions as they would appear on a command line.
0868     /// \param IncludePath The path to the module map file.
0869     /// \param APINotesFile The path to an API notes file for this module.
0870     /// \param File        Source file of the module.
0871     ///                    Used for Fortran modules.
0872     /// \param LineNo      Source line number of the module.
0873     ///                    Used for Fortran modules.
0874     /// \param IsDecl      This is a module declaration; default to false;
0875     ///                    when set to true, only Scope and Name are required
0876     ///                    as this entry is just a hint for the debugger to find
0877     ///                    the corresponding definition in the global scope.
0878     DIModule *createModule(DIScope *Scope, StringRef Name,
0879                            StringRef ConfigurationMacros, StringRef IncludePath,
0880                            StringRef APINotesFile = {}, DIFile *File = nullptr,
0881                            unsigned LineNo = 0, bool IsDecl = false);
0882 
0883     /// This creates a descriptor for a lexical block with a new file
0884     /// attached. This merely extends the existing
0885     /// lexical block as it crosses a file.
0886     /// \param Scope       Lexical block.
0887     /// \param File        Source file.
0888     /// \param Discriminator DWARF path discriminator value.
0889     DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
0890                                                unsigned Discriminator = 0);
0891 
0892     /// This creates a descriptor for a lexical block with the
0893     /// specified parent context.
0894     /// \param Scope         Parent lexical scope.
0895     /// \param File          Source file.
0896     /// \param Line          Line number.
0897     /// \param Col           Column number.
0898     DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
0899                                        unsigned Line, unsigned Col);
0900 
0901     /// Create a descriptor for an imported module.
0902     /// \param Context        The scope this module is imported into
0903     /// \param NS             The namespace being imported here.
0904     /// \param File           File where the declaration is located.
0905     /// \param Line           Line number of the declaration.
0906     /// \param Elements       Renamed elements.
0907     DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
0908                                            DIFile *File, unsigned Line,
0909                                            DINodeArray Elements = nullptr);
0910 
0911     /// Create a descriptor for an imported module.
0912     /// \param Context The scope this module is imported into.
0913     /// \param NS      An aliased namespace.
0914     /// \param File    File where the declaration is located.
0915     /// \param Line    Line number of the declaration.
0916     /// \param Elements       Renamed elements.
0917     DIImportedEntity *createImportedModule(DIScope *Context,
0918                                            DIImportedEntity *NS, DIFile *File,
0919                                            unsigned Line,
0920                                            DINodeArray Elements = nullptr);
0921 
0922     /// Create a descriptor for an imported module.
0923     /// \param Context        The scope this module is imported into.
0924     /// \param M              The module being imported here
0925     /// \param File           File where the declaration is located.
0926     /// \param Line           Line number of the declaration.
0927     /// \param Elements       Renamed elements.
0928     DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
0929                                            DIFile *File, unsigned Line,
0930                                            DINodeArray Elements = nullptr);
0931 
0932     /// Create a descriptor for an imported function.
0933     /// \param Context The scope this module is imported into.
0934     /// \param Decl    The declaration (or definition) of a function, type, or
0935     ///                variable.
0936     /// \param File    File where the declaration is located.
0937     /// \param Line    Line number of the declaration.
0938     /// \param Elements       Renamed elements.
0939     DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
0940                                                 DIFile *File, unsigned Line,
0941                                                 StringRef Name = "",
0942                                                 DINodeArray Elements = nullptr);
0943 
0944     /// Insert a new llvm.dbg.declare intrinsic call.
0945     /// \param Storage     llvm::Value of the variable
0946     /// \param VarInfo     Variable's debug info descriptor.
0947     /// \param Expr        A complex location expression.
0948     /// \param DL          Debug info location.
0949     /// \param InsertAtEnd Location for the new intrinsic.
0950     DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
0951                              DIExpression *Expr, const DILocation *DL,
0952                              BasicBlock *InsertAtEnd);
0953 
0954     /// Insert a new llvm.dbg.assign intrinsic call.
0955     /// \param LinkedInstr   Instruction with a DIAssignID to link with the new
0956     ///                      intrinsic. The intrinsic will be inserted after
0957     ///                      this instruction.
0958     /// \param Val           The value component of this dbg.assign.
0959     /// \param SrcVar        Variable's debug info descriptor.
0960     /// \param ValExpr       A complex location expression to modify \p Val.
0961     /// \param Addr          The address component (store destination).
0962     /// \param AddrExpr      A complex location expression to modify \p Addr.
0963     ///                      NOTE: \p ValExpr carries the FragInfo for the
0964     ///                      variable.
0965     /// \param DL            Debug info location, usually: (line: 0,
0966     ///                      column: 0, scope: var-decl-scope). See
0967     ///                      getDebugValueLoc.
0968     DbgInstPtr insertDbgAssign(Instruction *LinkedInstr, Value *Val,
0969                                DILocalVariable *SrcVar, DIExpression *ValExpr,
0970                                Value *Addr, DIExpression *AddrExpr,
0971                                const DILocation *DL);
0972 
0973     /// Insert a new llvm.dbg.declare intrinsic call.
0974     /// \param Storage      llvm::Value of the variable
0975     /// \param VarInfo      Variable's debug info descriptor.
0976     /// \param Expr         A complex location expression.
0977     /// \param DL           Debug info location.
0978     /// \param InsertPt     Location for the new intrinsic.
0979     DbgInstPtr insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
0980                              DIExpression *Expr, const DILocation *DL,
0981                              InsertPosition InsertPt);
0982 
0983     /// Insert a new llvm.dbg.label intrinsic call.
0984     /// \param LabelInfo    Label's debug info descriptor.
0985     /// \param DL           Debug info location.
0986     /// \param InsertBefore Location for the new intrinsic.
0987     DbgInstPtr insertLabel(DILabel *LabelInfo, const DILocation *DL,
0988                            InsertPosition InsertPt);
0989 
0990     /// Insert a new llvm.dbg.value intrinsic call.
0991     /// \param Val          llvm::Value of the variable
0992     /// \param VarInfo      Variable's debug info descriptor.
0993     /// \param Expr         A complex location expression.
0994     /// \param DL           Debug info location.
0995     /// \param InsertPt     Location for the new intrinsic.
0996     DbgInstPtr insertDbgValueIntrinsic(llvm::Value *Val,
0997                                        DILocalVariable *VarInfo,
0998                                        DIExpression *Expr, const DILocation *DL,
0999                                        InsertPosition InsertPt);
1000 
1001     /// Replace the vtable holder in the given type.
1002     ///
1003     /// If this creates a self reference, it may orphan some unresolved cycles
1004     /// in the operands of \c T, so \a DIBuilder needs to track that.
1005     void replaceVTableHolder(DICompositeType *&T,
1006                              DIType *VTableHolder);
1007 
1008     /// Replace arrays on a composite type.
1009     ///
1010     /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
1011     /// has a self-reference -- \a DIBuilder needs to track the array to
1012     /// resolve cycles.
1013     void replaceArrays(DICompositeType *&T, DINodeArray Elements,
1014                        DINodeArray TParams = DINodeArray());
1015 
1016     /// Replace a temporary node.
1017     ///
1018     /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
1019     /// Replacement.
1020     ///
1021     /// If \c Replacement is the same as \c N.get(), instead call \a
1022     /// MDNode::replaceWithUniqued().  In this case, the uniqued node could
1023     /// have a different address, so we return the final address.
1024     template <class NodeTy>
1025     NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
1026       if (N.get() == Replacement)
1027         return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
1028 
1029       N->replaceAllUsesWith(Replacement);
1030       return Replacement;
1031     }
1032   };
1033 
1034   // Create wrappers for C Binding types (see CBindingWrapping.h).
1035   DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)
1036 
1037 } // end namespace llvm
1038 
1039 #endif // LLVM_IR_DIBUILDER_H