DIBuilder.h 53 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===- DIBuilder.h - Debug Information Builder ------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. //
  14. // This file defines a DIBuilder that is useful for creating debugging
  15. // information entries in LLVM IR form.
  16. //
  17. //===----------------------------------------------------------------------===//
  18. #ifndef LLVM_IR_DIBUILDER_H
  19. #define LLVM_IR_DIBUILDER_H
  20. #include "llvm/ADT/ArrayRef.h"
  21. #include "llvm/ADT/DenseMap.h"
  22. #include "llvm/ADT/MapVector.h"
  23. #include "llvm/ADT/SetVector.h"
  24. #include "llvm/ADT/SmallVector.h"
  25. #include "llvm/ADT/StringRef.h"
  26. #include "llvm/BinaryFormat/Dwarf.h"
  27. #include "llvm/IR/DebugInfoMetadata.h"
  28. #include "llvm/IR/TrackingMDRef.h"
  29. #include "llvm/Support/Casting.h"
  30. #include <algorithm>
  31. #include <cstdint>
  32. #include <optional>
  33. namespace llvm {
  34. class BasicBlock;
  35. class Constant;
  36. class Function;
  37. class Instruction;
  38. class LLVMContext;
  39. class Module;
  40. class Value;
  41. class DbgAssignIntrinsic;
  42. class DIBuilder {
  43. Module &M;
  44. LLVMContext &VMContext;
  45. DICompileUnit *CUNode; ///< The one compile unit created by this DIBuiler.
  46. Function *DeclareFn; ///< llvm.dbg.declare
  47. Function *ValueFn; ///< llvm.dbg.value
  48. Function *LabelFn; ///< llvm.dbg.label
  49. Function *AddrFn; ///< llvm.dbg.addr
  50. Function *AssignFn; ///< llvm.dbg.assign
  51. SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
  52. /// Track the RetainTypes, since they can be updated later on.
  53. SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
  54. SmallVector<Metadata *, 4> AllSubprograms;
  55. SmallVector<Metadata *, 4> AllGVs;
  56. SmallVector<TrackingMDNodeRef, 4> AllImportedModules;
  57. /// Map Macro parent (which can be DIMacroFile or nullptr) to a list of
  58. /// Metadata all of type DIMacroNode.
  59. /// DIMacroNode's with nullptr parent are DICompileUnit direct children.
  60. MapVector<MDNode *, SetVector<Metadata *>> AllMacrosPerParent;
  61. /// Track nodes that may be unresolved.
  62. SmallVector<TrackingMDNodeRef, 4> UnresolvedNodes;
  63. bool AllowUnresolvedNodes;
  64. /// Each subprogram's preserved local variables.
  65. ///
  66. /// Do not use a std::vector. Some versions of libc++ apparently copy
  67. /// instead of move on grow operations, and TrackingMDRef is expensive to
  68. /// copy.
  69. DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedVariables;
  70. /// Each subprogram's preserved labels.
  71. DenseMap<MDNode *, SmallVector<TrackingMDNodeRef, 1>> PreservedLabels;
  72. /// Create a temporary.
  73. ///
  74. /// Create an \a temporary node and track it in \a UnresolvedNodes.
  75. void trackIfUnresolved(MDNode *N);
  76. /// Internal helper for insertDeclare.
  77. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  78. DIExpression *Expr, const DILocation *DL,
  79. BasicBlock *InsertBB, Instruction *InsertBefore);
  80. /// Internal helper for insertLabel.
  81. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  82. BasicBlock *InsertBB, Instruction *InsertBefore);
  83. /// Internal helper with common code used by insertDbg{Value,Addr}Intrinsic.
  84. Instruction *insertDbgIntrinsic(llvm::Function *Intrinsic, llvm::Value *Val,
  85. DILocalVariable *VarInfo,
  86. DIExpression *Expr, const DILocation *DL,
  87. BasicBlock *InsertBB,
  88. Instruction *InsertBefore);
  89. /// Internal helper for insertDbgValueIntrinsic.
  90. Instruction *
  91. insertDbgValueIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo,
  92. DIExpression *Expr, const DILocation *DL,
  93. BasicBlock *InsertBB, Instruction *InsertBefore);
  94. /// Internal helper for insertDbgAddrIntrinsic.
  95. Instruction *
  96. insertDbgAddrIntrinsic(llvm::Value *Val, DILocalVariable *VarInfo,
  97. DIExpression *Expr, const DILocation *DL,
  98. BasicBlock *InsertBB, Instruction *InsertBefore);
  99. public:
  100. /// Construct a builder for a module.
  101. ///
  102. /// If \c AllowUnresolved, collect unresolved nodes attached to the module
  103. /// in order to resolve cycles during \a finalize().
  104. ///
  105. /// If \p CU is given a value other than nullptr, then set \p CUNode to CU.
  106. explicit DIBuilder(Module &M, bool AllowUnresolved = true,
  107. DICompileUnit *CU = nullptr);
  108. DIBuilder(const DIBuilder &) = delete;
  109. DIBuilder &operator=(const DIBuilder &) = delete;
  110. /// Construct any deferred debug info descriptors.
  111. void finalize();
  112. /// Finalize a specific subprogram - no new variables may be added to this
  113. /// subprogram afterwards.
  114. void finalizeSubprogram(DISubprogram *SP);
  115. /// A CompileUnit provides an anchor for all debugging
  116. /// information generated during this instance of compilation.
  117. /// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
  118. /// \param File File info.
  119. /// \param Producer Identify the producer of debugging information
  120. /// and code. Usually this is a compiler
  121. /// version string.
  122. /// \param isOptimized A boolean flag which indicates whether optimization
  123. /// is enabled or not.
  124. /// \param Flags This string lists command line options. This
  125. /// string is directly embedded in debug info
  126. /// output which may be used by a tool
  127. /// analyzing generated debugging information.
  128. /// \param RV This indicates runtime version for languages like
  129. /// Objective-C.
  130. /// \param SplitName The name of the file that we'll split debug info
  131. /// out into.
  132. /// \param Kind The kind of debug information to generate.
  133. /// \param DWOId The DWOId if this is a split skeleton compile unit.
  134. /// \param SplitDebugInlining Whether to emit inline debug info.
  135. /// \param DebugInfoForProfiling Whether to emit extra debug info for
  136. /// profile collection.
  137. /// \param NameTableKind Whether to emit .debug_gnu_pubnames,
  138. /// .debug_pubnames, or no pubnames at all.
  139. /// \param SysRoot The clang system root (value of -isysroot).
  140. /// \param SDK The SDK name. On Darwin, this is the last component
  141. /// of the sysroot.
  142. DICompileUnit *
  143. createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
  144. bool isOptimized, StringRef Flags, unsigned RV,
  145. StringRef SplitName = StringRef(),
  146. DICompileUnit::DebugEmissionKind Kind =
  147. DICompileUnit::DebugEmissionKind::FullDebug,
  148. uint64_t DWOId = 0, bool SplitDebugInlining = true,
  149. bool DebugInfoForProfiling = false,
  150. DICompileUnit::DebugNameTableKind NameTableKind =
  151. DICompileUnit::DebugNameTableKind::Default,
  152. bool RangesBaseAddress = false, StringRef SysRoot = {},
  153. StringRef SDK = {});
  154. /// Create a file descriptor to hold debugging information for a file.
  155. /// \param Filename File name.
  156. /// \param Directory Directory.
  157. /// \param Checksum Optional checksum kind (e.g. CSK_MD5, CSK_SHA1, etc.)
  158. /// and value.
  159. /// \param Source Optional source text.
  160. DIFile *createFile(
  161. StringRef Filename, StringRef Directory,
  162. std::optional<DIFile::ChecksumInfo<StringRef>> Checksum = std::nullopt,
  163. std::optional<StringRef> Source = std::nullopt);
  164. /// Create debugging information entry for a macro.
  165. /// \param Parent Macro parent (could be nullptr).
  166. /// \param Line Source line number where the macro is defined.
  167. /// \param MacroType DW_MACINFO_define or DW_MACINFO_undef.
  168. /// \param Name Macro name.
  169. /// \param Value Macro value.
  170. DIMacro *createMacro(DIMacroFile *Parent, unsigned Line, unsigned MacroType,
  171. StringRef Name, StringRef Value = StringRef());
  172. /// Create debugging information temporary entry for a macro file.
  173. /// List of macro node direct children will be calculated by DIBuilder,
  174. /// using the \p Parent relationship.
  175. /// \param Parent Macro file parent (could be nullptr).
  176. /// \param Line Source line number where the macro file is included.
  177. /// \param File File descriptor containing the name of the macro file.
  178. DIMacroFile *createTempMacroFile(DIMacroFile *Parent, unsigned Line,
  179. DIFile *File);
  180. /// Create a single enumerator value.
  181. DIEnumerator *createEnumerator(StringRef Name, const APSInt &Value);
  182. DIEnumerator *createEnumerator(StringRef Name, uint64_t Val,
  183. bool IsUnsigned = false);
  184. /// Create a DWARF unspecified type.
  185. DIBasicType *createUnspecifiedType(StringRef Name);
  186. /// Create C++11 nullptr type.
  187. DIBasicType *createNullPtrType();
  188. /// Create debugging information entry for a basic
  189. /// type.
  190. /// \param Name Type name.
  191. /// \param SizeInBits Size of the type.
  192. /// \param Encoding DWARF encoding code, e.g., dwarf::DW_ATE_float.
  193. /// \param Flags Optional DWARF attributes, e.g., DW_AT_endianity.
  194. DIBasicType *createBasicType(StringRef Name, uint64_t SizeInBits,
  195. unsigned Encoding,
  196. DINode::DIFlags Flags = DINode::FlagZero);
  197. /// Create debugging information entry for a string
  198. /// type.
  199. /// \param Name Type name.
  200. /// \param SizeInBits Size of the type.
  201. DIStringType *createStringType(StringRef Name, uint64_t SizeInBits);
  202. /// Create debugging information entry for Fortran
  203. /// assumed length string type.
  204. /// \param Name Type name.
  205. /// \param StringLength String length expressed as DIVariable *.
  206. /// \param StrLocationExp Optional memory location of the string.
  207. DIStringType *createStringType(StringRef Name, DIVariable *StringLength,
  208. DIExpression *StrLocationExp = nullptr);
  209. /// Create debugging information entry for Fortran
  210. /// assumed length string type.
  211. /// \param Name Type name.
  212. /// \param StringLengthExp String length expressed in DIExpression form.
  213. /// \param StrLocationExp Optional memory location of the string.
  214. DIStringType *createStringType(StringRef Name,
  215. DIExpression *StringLengthExp,
  216. DIExpression *StrLocationExp = nullptr);
  217. /// Create debugging information entry for a qualified
  218. /// type, e.g. 'const int'.
  219. /// \param Tag Tag identifing type, e.g. dwarf::TAG_volatile_type
  220. /// \param FromTy Base Type.
  221. DIDerivedType *createQualifiedType(unsigned Tag, DIType *FromTy);
  222. /// Create debugging information entry for a pointer.
  223. /// \param PointeeTy Type pointed by this pointer.
  224. /// \param SizeInBits Size.
  225. /// \param AlignInBits Alignment. (optional)
  226. /// \param DWARFAddressSpace DWARF address space. (optional)
  227. /// \param Name Pointer type name. (optional)
  228. /// \param Annotations Member annotations.
  229. DIDerivedType *
  230. createPointerType(DIType *PointeeTy, uint64_t SizeInBits,
  231. uint32_t AlignInBits = 0,
  232. std::optional<unsigned> DWARFAddressSpace = std::nullopt,
  233. StringRef Name = "", DINodeArray Annotations = nullptr);
  234. /// Create debugging information entry for a pointer to member.
  235. /// \param PointeeTy Type pointed to by this pointer.
  236. /// \param SizeInBits Size.
  237. /// \param AlignInBits Alignment. (optional)
  238. /// \param Class Type for which this pointer points to members of.
  239. DIDerivedType *
  240. createMemberPointerType(DIType *PointeeTy, DIType *Class,
  241. uint64_t SizeInBits, uint32_t AlignInBits = 0,
  242. DINode::DIFlags Flags = DINode::FlagZero);
  243. /// Create debugging information entry for a c++
  244. /// style reference or rvalue reference type.
  245. DIDerivedType *createReferenceType(
  246. unsigned Tag, DIType *RTy, uint64_t SizeInBits = 0,
  247. uint32_t AlignInBits = 0,
  248. std::optional<unsigned> DWARFAddressSpace = std::nullopt);
  249. /// Create debugging information entry for a typedef.
  250. /// \param Ty Original type.
  251. /// \param Name Typedef name.
  252. /// \param File File where this type is defined.
  253. /// \param LineNo Line number.
  254. /// \param Context The surrounding context for the typedef.
  255. /// \param AlignInBits Alignment. (optional)
  256. /// \param Flags Flags to describe inheritance attribute, e.g. private
  257. /// \param Annotations Annotations. (optional)
  258. DIDerivedType *createTypedef(DIType *Ty, StringRef Name, DIFile *File,
  259. unsigned LineNo, DIScope *Context,
  260. uint32_t AlignInBits = 0,
  261. DINode::DIFlags Flags = DINode::FlagZero,
  262. DINodeArray Annotations = nullptr);
  263. /// Create debugging information entry for a 'friend'.
  264. DIDerivedType *createFriend(DIType *Ty, DIType *FriendTy);
  265. /// Create debugging information entry to establish
  266. /// inheritance relationship between two types.
  267. /// \param Ty Original type.
  268. /// \param BaseTy Base type. Ty is inherits from base.
  269. /// \param BaseOffset Base offset.
  270. /// \param VBPtrOffset Virtual base pointer offset.
  271. /// \param Flags Flags to describe inheritance attribute,
  272. /// e.g. private
  273. DIDerivedType *createInheritance(DIType *Ty, DIType *BaseTy,
  274. uint64_t BaseOffset, uint32_t VBPtrOffset,
  275. DINode::DIFlags Flags);
  276. /// Create debugging information entry for a member.
  277. /// \param Scope Member scope.
  278. /// \param Name Member name.
  279. /// \param File File where this member is defined.
  280. /// \param LineNo Line number.
  281. /// \param SizeInBits Member size.
  282. /// \param AlignInBits Member alignment.
  283. /// \param OffsetInBits Member offset.
  284. /// \param Flags Flags to encode member attribute, e.g. private
  285. /// \param Ty Parent type.
  286. /// \param Annotations Member annotations.
  287. DIDerivedType *createMemberType(DIScope *Scope, StringRef Name,
  288. DIFile *File, unsigned LineNo,
  289. uint64_t SizeInBits, uint32_t AlignInBits,
  290. uint64_t OffsetInBits,
  291. DINode::DIFlags Flags, DIType *Ty,
  292. DINodeArray Annotations = nullptr);
  293. /// Create debugging information entry for a variant. A variant
  294. /// normally should be a member of a variant part.
  295. /// \param Scope Member scope.
  296. /// \param Name Member name.
  297. /// \param File File where this member is defined.
  298. /// \param LineNo Line number.
  299. /// \param SizeInBits Member size.
  300. /// \param AlignInBits Member alignment.
  301. /// \param OffsetInBits Member offset.
  302. /// \param Flags Flags to encode member attribute, e.g. private
  303. /// \param Discriminant The discriminant for this branch; null for
  304. /// the default branch
  305. /// \param Ty Parent type.
  306. DIDerivedType *createVariantMemberType(DIScope *Scope, StringRef Name,
  307. DIFile *File, unsigned LineNo,
  308. uint64_t SizeInBits,
  309. uint32_t AlignInBits,
  310. uint64_t OffsetInBits,
  311. Constant *Discriminant,
  312. DINode::DIFlags Flags, DIType *Ty);
  313. /// Create debugging information entry for a bit field member.
  314. /// \param Scope Member scope.
  315. /// \param Name Member name.
  316. /// \param File File where this member is defined.
  317. /// \param LineNo Line number.
  318. /// \param SizeInBits Member size.
  319. /// \param OffsetInBits Member offset.
  320. /// \param StorageOffsetInBits Member storage offset.
  321. /// \param Flags Flags to encode member attribute.
  322. /// \param Ty Parent type.
  323. /// \param Annotations Member annotations.
  324. DIDerivedType *createBitFieldMemberType(DIScope *Scope, StringRef Name,
  325. DIFile *File, unsigned LineNo,
  326. uint64_t SizeInBits,
  327. uint64_t OffsetInBits,
  328. uint64_t StorageOffsetInBits,
  329. DINode::DIFlags Flags, DIType *Ty,
  330. DINodeArray Annotations = nullptr);
  331. /// Create debugging information entry for a
  332. /// C++ static data member.
  333. /// \param Scope Member scope.
  334. /// \param Name Member name.
  335. /// \param File File where this member is declared.
  336. /// \param LineNo Line number.
  337. /// \param Ty Type of the static member.
  338. /// \param Flags Flags to encode member attribute, e.g. private.
  339. /// \param Val Const initializer of the member.
  340. /// \param AlignInBits Member alignment.
  341. DIDerivedType *createStaticMemberType(DIScope *Scope, StringRef Name,
  342. DIFile *File, unsigned LineNo,
  343. DIType *Ty, DINode::DIFlags Flags,
  344. Constant *Val,
  345. uint32_t AlignInBits = 0);
  346. /// Create debugging information entry for Objective-C
  347. /// instance variable.
  348. /// \param Name Member name.
  349. /// \param File File where this member is defined.
  350. /// \param LineNo Line number.
  351. /// \param SizeInBits Member size.
  352. /// \param AlignInBits Member alignment.
  353. /// \param OffsetInBits Member offset.
  354. /// \param Flags Flags to encode member attribute, e.g. private
  355. /// \param Ty Parent type.
  356. /// \param PropertyNode Property associated with this ivar.
  357. DIDerivedType *createObjCIVar(StringRef Name, DIFile *File, unsigned LineNo,
  358. uint64_t SizeInBits, uint32_t AlignInBits,
  359. uint64_t OffsetInBits, DINode::DIFlags Flags,
  360. DIType *Ty, MDNode *PropertyNode);
  361. /// Create debugging information entry for Objective-C
  362. /// property.
  363. /// \param Name Property name.
  364. /// \param File File where this property is defined.
  365. /// \param LineNumber Line number.
  366. /// \param GetterName Name of the Objective C property getter selector.
  367. /// \param SetterName Name of the Objective C property setter selector.
  368. /// \param PropertyAttributes Objective C property attributes.
  369. /// \param Ty Type.
  370. DIObjCProperty *createObjCProperty(StringRef Name, DIFile *File,
  371. unsigned LineNumber,
  372. StringRef GetterName,
  373. StringRef SetterName,
  374. unsigned PropertyAttributes, DIType *Ty);
  375. /// Create debugging information entry for a class.
  376. /// \param Scope Scope in which this class is defined.
  377. /// \param Name class name.
  378. /// \param File File where this member is defined.
  379. /// \param LineNumber Line number.
  380. /// \param SizeInBits Member size.
  381. /// \param AlignInBits Member alignment.
  382. /// \param OffsetInBits Member offset.
  383. /// \param Flags Flags to encode member attribute, e.g. private
  384. /// \param Elements class members.
  385. /// \param VTableHolder Debug info of the base class that contains vtable
  386. /// for this type. This is used in
  387. /// DW_AT_containing_type. See DWARF documentation
  388. /// for more info.
  389. /// \param TemplateParms Template type parameters.
  390. /// \param UniqueIdentifier A unique identifier for the class.
  391. DICompositeType *createClassType(
  392. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  393. uint64_t SizeInBits, uint32_t AlignInBits, uint64_t OffsetInBits,
  394. DINode::DIFlags Flags, DIType *DerivedFrom, DINodeArray Elements,
  395. DIType *VTableHolder = nullptr, MDNode *TemplateParms = nullptr,
  396. StringRef UniqueIdentifier = "");
  397. /// Create debugging information entry for a struct.
  398. /// \param Scope Scope in which this struct is defined.
  399. /// \param Name Struct name.
  400. /// \param File File where this member is defined.
  401. /// \param LineNumber Line number.
  402. /// \param SizeInBits Member size.
  403. /// \param AlignInBits Member alignment.
  404. /// \param Flags Flags to encode member attribute, e.g. private
  405. /// \param Elements Struct elements.
  406. /// \param RunTimeLang Optional parameter, Objective-C runtime version.
  407. /// \param UniqueIdentifier A unique identifier for the struct.
  408. DICompositeType *createStructType(
  409. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  410. uint64_t SizeInBits, uint32_t AlignInBits, DINode::DIFlags Flags,
  411. DIType *DerivedFrom, DINodeArray Elements, unsigned RunTimeLang = 0,
  412. DIType *VTableHolder = nullptr, StringRef UniqueIdentifier = "");
  413. /// Create debugging information entry for an union.
  414. /// \param Scope Scope in which this union is defined.
  415. /// \param Name Union name.
  416. /// \param File File where this member is defined.
  417. /// \param LineNumber Line number.
  418. /// \param SizeInBits Member size.
  419. /// \param AlignInBits Member alignment.
  420. /// \param Flags Flags to encode member attribute, e.g. private
  421. /// \param Elements Union elements.
  422. /// \param RunTimeLang Optional parameter, Objective-C runtime version.
  423. /// \param UniqueIdentifier A unique identifier for the union.
  424. DICompositeType *createUnionType(DIScope *Scope, StringRef Name,
  425. DIFile *File, unsigned LineNumber,
  426. uint64_t SizeInBits, uint32_t AlignInBits,
  427. DINode::DIFlags Flags,
  428. DINodeArray Elements,
  429. unsigned RunTimeLang = 0,
  430. StringRef UniqueIdentifier = "");
  431. /// Create debugging information entry for a variant part. A
  432. /// variant part normally has a discriminator (though this is not
  433. /// required) and a number of variant children.
  434. /// \param Scope Scope in which this union is defined.
  435. /// \param Name Union name.
  436. /// \param File File where this member is defined.
  437. /// \param LineNumber Line number.
  438. /// \param SizeInBits Member size.
  439. /// \param AlignInBits Member alignment.
  440. /// \param Flags Flags to encode member attribute, e.g. private
  441. /// \param Discriminator Discriminant member
  442. /// \param Elements Variant elements.
  443. /// \param UniqueIdentifier A unique identifier for the union.
  444. DICompositeType *createVariantPart(DIScope *Scope, StringRef Name,
  445. DIFile *File, unsigned LineNumber,
  446. uint64_t SizeInBits, uint32_t AlignInBits,
  447. DINode::DIFlags Flags,
  448. DIDerivedType *Discriminator,
  449. DINodeArray Elements,
  450. StringRef UniqueIdentifier = "");
  451. /// Create debugging information for template
  452. /// type parameter.
  453. /// \param Scope Scope in which this type is defined.
  454. /// \param Name Type parameter name.
  455. /// \param Ty Parameter type.
  456. /// \param IsDefault Parameter is default or not
  457. DITemplateTypeParameter *createTemplateTypeParameter(DIScope *Scope,
  458. StringRef Name,
  459. DIType *Ty,
  460. bool IsDefault);
  461. /// Create debugging information for template
  462. /// value parameter.
  463. /// \param Scope Scope in which this type is defined.
  464. /// \param Name Value parameter name.
  465. /// \param Ty Parameter type.
  466. /// \param IsDefault Parameter is default or not
  467. /// \param Val Constant parameter value.
  468. DITemplateValueParameter *
  469. createTemplateValueParameter(DIScope *Scope, StringRef Name, DIType *Ty,
  470. bool IsDefault, Constant *Val);
  471. /// Create debugging information for a template template parameter.
  472. /// \param Scope Scope in which this type is defined.
  473. /// \param Name Value parameter name.
  474. /// \param Ty Parameter type.
  475. /// \param Val The fully qualified name of the template.
  476. /// \param IsDefault Parameter is default or not.
  477. DITemplateValueParameter *
  478. createTemplateTemplateParameter(DIScope *Scope, StringRef Name, DIType *Ty,
  479. StringRef Val, bool IsDefault = false);
  480. /// Create debugging information for a template parameter pack.
  481. /// \param Scope Scope in which this type is defined.
  482. /// \param Name Value parameter name.
  483. /// \param Ty Parameter type.
  484. /// \param Val An array of types in the pack.
  485. DITemplateValueParameter *createTemplateParameterPack(DIScope *Scope,
  486. StringRef Name,
  487. DIType *Ty,
  488. DINodeArray Val);
  489. /// Create debugging information entry for an array.
  490. /// \param Size Array size.
  491. /// \param AlignInBits Alignment.
  492. /// \param Ty Element type.
  493. /// \param Subscripts Subscripts.
  494. /// \param DataLocation The location of the raw data of a descriptor-based
  495. /// Fortran array, either a DIExpression* or
  496. /// a DIVariable*.
  497. /// \param Associated The associated attribute of a descriptor-based
  498. /// Fortran array, either a DIExpression* or
  499. /// a DIVariable*.
  500. /// \param Allocated The allocated attribute of a descriptor-based
  501. /// Fortran array, either a DIExpression* or
  502. /// a DIVariable*.
  503. /// \param Rank The rank attribute of a descriptor-based
  504. /// Fortran array, either a DIExpression* or
  505. /// a DIVariable*.
  506. DICompositeType *createArrayType(
  507. uint64_t Size, uint32_t AlignInBits, DIType *Ty, DINodeArray Subscripts,
  508. PointerUnion<DIExpression *, DIVariable *> DataLocation = nullptr,
  509. PointerUnion<DIExpression *, DIVariable *> Associated = nullptr,
  510. PointerUnion<DIExpression *, DIVariable *> Allocated = nullptr,
  511. PointerUnion<DIExpression *, DIVariable *> Rank = nullptr);
  512. /// Create debugging information entry for a vector type.
  513. /// \param Size Array size.
  514. /// \param AlignInBits Alignment.
  515. /// \param Ty Element type.
  516. /// \param Subscripts Subscripts.
  517. DICompositeType *createVectorType(uint64_t Size, uint32_t AlignInBits,
  518. DIType *Ty, DINodeArray Subscripts);
  519. /// Create debugging information entry for an
  520. /// enumeration.
  521. /// \param Scope Scope in which this enumeration is defined.
  522. /// \param Name Union name.
  523. /// \param File File where this member is defined.
  524. /// \param LineNumber Line number.
  525. /// \param SizeInBits Member size.
  526. /// \param AlignInBits Member alignment.
  527. /// \param Elements Enumeration elements.
  528. /// \param UnderlyingType Underlying type of a C++11/ObjC fixed enum.
  529. /// \param UniqueIdentifier A unique identifier for the enum.
  530. /// \param IsScoped Boolean flag indicate if this is C++11/ObjC 'enum class'.
  531. DICompositeType *createEnumerationType(
  532. DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNumber,
  533. uint64_t SizeInBits, uint32_t AlignInBits, DINodeArray Elements,
  534. DIType *UnderlyingType, StringRef UniqueIdentifier = "", bool IsScoped = false);
  535. /// Create debugging information entry for a set.
  536. /// \param Scope Scope in which this set is defined.
  537. /// \param Name Set name.
  538. /// \param File File where this set is defined.
  539. /// \param LineNo Line number.
  540. /// \param SizeInBits Set size.
  541. /// \param AlignInBits Set alignment.
  542. /// \param Ty Base type of the set.
  543. DIDerivedType *createSetType(DIScope *Scope, StringRef Name, DIFile *File,
  544. unsigned LineNo, uint64_t SizeInBits,
  545. uint32_t AlignInBits, DIType *Ty);
  546. /// Create subroutine type.
  547. /// \param ParameterTypes An array of subroutine parameter types. This
  548. /// includes return type at 0th index.
  549. /// \param Flags E.g.: LValueReference.
  550. /// These flags are used to emit dwarf attributes.
  551. /// \param CC Calling convention, e.g. dwarf::DW_CC_normal
  552. DISubroutineType *
  553. createSubroutineType(DITypeRefArray ParameterTypes,
  554. DINode::DIFlags Flags = DINode::FlagZero,
  555. unsigned CC = 0);
  556. /// Create a distinct clone of \p SP with FlagArtificial set.
  557. static DISubprogram *createArtificialSubprogram(DISubprogram *SP);
  558. /// Create a uniqued clone of \p Ty with FlagArtificial set.
  559. static DIType *createArtificialType(DIType *Ty);
  560. /// Create a uniqued clone of \p Ty with FlagObjectPointer and
  561. /// FlagArtificial set.
  562. static DIType *createObjectPointerType(DIType *Ty);
  563. /// Create a permanent forward-declared type.
  564. DICompositeType *createForwardDecl(unsigned Tag, StringRef Name,
  565. DIScope *Scope, DIFile *F, unsigned Line,
  566. unsigned RuntimeLang = 0,
  567. uint64_t SizeInBits = 0,
  568. uint32_t AlignInBits = 0,
  569. StringRef UniqueIdentifier = "");
  570. /// Create a temporary forward-declared type.
  571. DICompositeType *createReplaceableCompositeType(
  572. unsigned Tag, StringRef Name, DIScope *Scope, DIFile *F, unsigned Line,
  573. unsigned RuntimeLang = 0, uint64_t SizeInBits = 0,
  574. uint32_t AlignInBits = 0, DINode::DIFlags Flags = DINode::FlagFwdDecl,
  575. StringRef UniqueIdentifier = "", DINodeArray Annotations = nullptr);
  576. /// Retain DIScope* in a module even if it is not referenced
  577. /// through debug info anchors.
  578. void retainType(DIScope *T);
  579. /// Create unspecified parameter type
  580. /// for a subroutine type.
  581. DIBasicType *createUnspecifiedParameter();
  582. /// Get a DINodeArray, create one if required.
  583. DINodeArray getOrCreateArray(ArrayRef<Metadata *> Elements);
  584. /// Get a DIMacroNodeArray, create one if required.
  585. DIMacroNodeArray getOrCreateMacroArray(ArrayRef<Metadata *> Elements);
  586. /// Get a DITypeRefArray, create one if required.
  587. DITypeRefArray getOrCreateTypeArray(ArrayRef<Metadata *> Elements);
  588. /// Create a descriptor for a value range. This
  589. /// implicitly uniques the values returned.
  590. DISubrange *getOrCreateSubrange(int64_t Lo, int64_t Count);
  591. DISubrange *getOrCreateSubrange(int64_t Lo, Metadata *CountNode);
  592. DISubrange *getOrCreateSubrange(Metadata *Count, Metadata *LowerBound,
  593. Metadata *UpperBound, Metadata *Stride);
  594. DIGenericSubrange *
  595. getOrCreateGenericSubrange(DIGenericSubrange::BoundType Count,
  596. DIGenericSubrange::BoundType LowerBound,
  597. DIGenericSubrange::BoundType UpperBound,
  598. DIGenericSubrange::BoundType Stride);
  599. /// Create a new descriptor for the specified variable.
  600. /// \param Context Variable scope.
  601. /// \param Name Name of the variable.
  602. /// \param LinkageName Mangled name of the variable.
  603. /// \param File File where this variable is defined.
  604. /// \param LineNo Line number.
  605. /// \param Ty Variable Type.
  606. /// \param IsLocalToUnit Boolean flag indicate whether this variable is
  607. /// externally visible or not.
  608. /// \param Expr The location of the global relative to the attached
  609. /// GlobalVariable.
  610. /// \param Decl Reference to the corresponding declaration.
  611. /// \param AlignInBits Variable alignment(or 0 if no alignment attr was
  612. /// specified)
  613. DIGlobalVariableExpression *createGlobalVariableExpression(
  614. DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
  615. unsigned LineNo, DIType *Ty, bool IsLocalToUnit, bool isDefined = true,
  616. DIExpression *Expr = nullptr, MDNode *Decl = nullptr,
  617. MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0,
  618. DINodeArray Annotations = nullptr);
  619. /// Identical to createGlobalVariable
  620. /// except that the resulting DbgNode is temporary and meant to be RAUWed.
  621. DIGlobalVariable *createTempGlobalVariableFwdDecl(
  622. DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
  623. unsigned LineNo, DIType *Ty, bool IsLocalToUnit, MDNode *Decl = nullptr,
  624. MDTuple *TemplateParams = nullptr, uint32_t AlignInBits = 0);
  625. /// Create a new descriptor for an auto variable. This is a local variable
  626. /// that is not a subprogram parameter.
  627. ///
  628. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  629. /// leads to a \a DISubprogram.
  630. ///
  631. /// If \c AlwaysPreserve, this variable will be referenced from its
  632. /// containing subprogram, and will survive some optimizations.
  633. DILocalVariable *
  634. createAutoVariable(DIScope *Scope, StringRef Name, DIFile *File,
  635. unsigned LineNo, DIType *Ty, bool AlwaysPreserve = false,
  636. DINode::DIFlags Flags = DINode::FlagZero,
  637. uint32_t AlignInBits = 0);
  638. /// Create a new descriptor for an label.
  639. ///
  640. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  641. /// leads to a \a DISubprogram.
  642. DILabel *
  643. createLabel(DIScope *Scope, StringRef Name, DIFile *File, unsigned LineNo,
  644. bool AlwaysPreserve = false);
  645. /// Create a new descriptor for a parameter variable.
  646. ///
  647. /// \c Scope must be a \a DILocalScope, and thus its scope chain eventually
  648. /// leads to a \a DISubprogram.
  649. ///
  650. /// \c ArgNo is the index (starting from \c 1) of this variable in the
  651. /// subprogram parameters. \c ArgNo should not conflict with other
  652. /// parameters of the same subprogram.
  653. ///
  654. /// If \c AlwaysPreserve, this variable will be referenced from its
  655. /// containing subprogram, and will survive some optimizations.
  656. DILocalVariable *
  657. createParameterVariable(DIScope *Scope, StringRef Name, unsigned ArgNo,
  658. DIFile *File, unsigned LineNo, DIType *Ty,
  659. bool AlwaysPreserve = false,
  660. DINode::DIFlags Flags = DINode::FlagZero,
  661. DINodeArray Annotations = nullptr);
  662. /// Create a new descriptor for the specified
  663. /// variable which has a complex address expression for its address.
  664. /// \param Addr An array of complex address operations.
  665. DIExpression *createExpression(ArrayRef<uint64_t> Addr = std::nullopt);
  666. /// Create an expression for a variable that does not have an address, but
  667. /// does have a constant value.
  668. DIExpression *createConstantValueExpression(uint64_t Val) {
  669. return DIExpression::get(
  670. VMContext, {dwarf::DW_OP_constu, Val, dwarf::DW_OP_stack_value});
  671. }
  672. /// Create a new descriptor for the specified subprogram.
  673. /// See comments in DISubprogram* for descriptions of these fields.
  674. /// \param Scope Function scope.
  675. /// \param Name Function name.
  676. /// \param LinkageName Mangled function name.
  677. /// \param File File where this variable is defined.
  678. /// \param LineNo Line number.
  679. /// \param Ty Function type.
  680. /// \param ScopeLine Set to the beginning of the scope this starts
  681. /// \param Flags e.g. is this function prototyped or not.
  682. /// These flags are used to emit dwarf attributes.
  683. /// \param SPFlags Additional flags specific to subprograms.
  684. /// \param TParams Function template parameters.
  685. /// \param ThrownTypes Exception types this function may throw.
  686. /// \param Annotations Attribute Annotations.
  687. /// \param TargetFuncName The name of the target function if this is
  688. /// a trampoline.
  689. DISubprogram *
  690. createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName,
  691. DIFile *File, unsigned LineNo, DISubroutineType *Ty,
  692. unsigned ScopeLine, DINode::DIFlags Flags = DINode::FlagZero,
  693. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  694. DITemplateParameterArray TParams = nullptr,
  695. DISubprogram *Decl = nullptr,
  696. DITypeArray ThrownTypes = nullptr,
  697. DINodeArray Annotations = nullptr,
  698. StringRef TargetFuncName = "");
  699. /// Identical to createFunction,
  700. /// except that the resulting DbgNode is meant to be RAUWed.
  701. DISubprogram *createTempFunctionFwdDecl(
  702. DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File,
  703. unsigned LineNo, DISubroutineType *Ty, unsigned ScopeLine,
  704. DINode::DIFlags Flags = DINode::FlagZero,
  705. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  706. DITemplateParameterArray TParams = nullptr,
  707. DISubprogram *Decl = nullptr, DITypeArray ThrownTypes = nullptr);
  708. /// Create a new descriptor for the specified C++ method.
  709. /// See comments in \a DISubprogram* for descriptions of these fields.
  710. /// \param Scope Function scope.
  711. /// \param Name Function name.
  712. /// \param LinkageName Mangled function name.
  713. /// \param File File where this variable is defined.
  714. /// \param LineNo Line number.
  715. /// \param Ty Function type.
  716. /// \param VTableIndex Index no of this method in virtual table, or -1u if
  717. /// unrepresentable.
  718. /// \param ThisAdjustment
  719. /// MS ABI-specific adjustment of 'this' that occurs
  720. /// in the prologue.
  721. /// \param VTableHolder Type that holds vtable.
  722. /// \param Flags e.g. is this function prototyped or not.
  723. /// This flags are used to emit dwarf attributes.
  724. /// \param SPFlags Additional flags specific to subprograms.
  725. /// \param TParams Function template parameters.
  726. /// \param ThrownTypes Exception types this function may throw.
  727. DISubprogram *
  728. createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName,
  729. DIFile *File, unsigned LineNo, DISubroutineType *Ty,
  730. unsigned VTableIndex = 0, int ThisAdjustment = 0,
  731. DIType *VTableHolder = nullptr,
  732. DINode::DIFlags Flags = DINode::FlagZero,
  733. DISubprogram::DISPFlags SPFlags = DISubprogram::SPFlagZero,
  734. DITemplateParameterArray TParams = nullptr,
  735. DITypeArray ThrownTypes = nullptr);
  736. /// Create common block entry for a Fortran common block.
  737. /// \param Scope Scope of this common block.
  738. /// \param decl Global variable declaration.
  739. /// \param Name The name of this common block.
  740. /// \param File The file this common block is defined.
  741. /// \param LineNo Line number.
  742. DICommonBlock *createCommonBlock(DIScope *Scope, DIGlobalVariable *decl,
  743. StringRef Name, DIFile *File,
  744. unsigned LineNo);
  745. /// This creates new descriptor for a namespace with the specified
  746. /// parent scope.
  747. /// \param Scope Namespace scope
  748. /// \param Name Name of this namespace
  749. /// \param ExportSymbols True for C++ inline namespaces.
  750. DINamespace *createNameSpace(DIScope *Scope, StringRef Name,
  751. bool ExportSymbols);
  752. /// This creates new descriptor for a module with the specified
  753. /// parent scope.
  754. /// \param Scope Parent scope
  755. /// \param Name Name of this module
  756. /// \param ConfigurationMacros
  757. /// A space-separated shell-quoted list of -D macro
  758. /// definitions as they would appear on a command line.
  759. /// \param IncludePath The path to the module map file.
  760. /// \param APINotesFile The path to an API notes file for this module.
  761. /// \param File Source file of the module.
  762. /// Used for Fortran modules.
  763. /// \param LineNo Source line number of the module.
  764. /// Used for Fortran modules.
  765. /// \param IsDecl This is a module declaration; default to false;
  766. /// when set to true, only Scope and Name are required
  767. /// as this entry is just a hint for the debugger to find
  768. /// the corresponding definition in the global scope.
  769. DIModule *createModule(DIScope *Scope, StringRef Name,
  770. StringRef ConfigurationMacros, StringRef IncludePath,
  771. StringRef APINotesFile = {}, DIFile *File = nullptr,
  772. unsigned LineNo = 0, bool IsDecl = false);
  773. /// This creates a descriptor for a lexical block with a new file
  774. /// attached. This merely extends the existing
  775. /// lexical block as it crosses a file.
  776. /// \param Scope Lexical block.
  777. /// \param File Source file.
  778. /// \param Discriminator DWARF path discriminator value.
  779. DILexicalBlockFile *createLexicalBlockFile(DIScope *Scope, DIFile *File,
  780. unsigned Discriminator = 0);
  781. /// This creates a descriptor for a lexical block with the
  782. /// specified parent context.
  783. /// \param Scope Parent lexical scope.
  784. /// \param File Source file.
  785. /// \param Line Line number.
  786. /// \param Col Column number.
  787. DILexicalBlock *createLexicalBlock(DIScope *Scope, DIFile *File,
  788. unsigned Line, unsigned Col);
  789. /// Create a descriptor for an imported module.
  790. /// \param Context The scope this module is imported into
  791. /// \param NS The namespace being imported here.
  792. /// \param File File where the declaration is located.
  793. /// \param Line Line number of the declaration.
  794. /// \param Elements Renamed elements.
  795. DIImportedEntity *createImportedModule(DIScope *Context, DINamespace *NS,
  796. DIFile *File, unsigned Line,
  797. DINodeArray Elements = nullptr);
  798. /// Create a descriptor for an imported module.
  799. /// \param Context The scope this module is imported into.
  800. /// \param NS An aliased namespace.
  801. /// \param File File where the declaration is located.
  802. /// \param Line Line number of the declaration.
  803. /// \param Elements Renamed elements.
  804. DIImportedEntity *createImportedModule(DIScope *Context,
  805. DIImportedEntity *NS, DIFile *File,
  806. unsigned Line,
  807. DINodeArray Elements = nullptr);
  808. /// Create a descriptor for an imported module.
  809. /// \param Context The scope this module is imported into.
  810. /// \param M The module being imported here
  811. /// \param File File where the declaration is located.
  812. /// \param Line Line number of the declaration.
  813. /// \param Elements Renamed elements.
  814. DIImportedEntity *createImportedModule(DIScope *Context, DIModule *M,
  815. DIFile *File, unsigned Line,
  816. DINodeArray Elements = nullptr);
  817. /// Create a descriptor for an imported function.
  818. /// \param Context The scope this module is imported into.
  819. /// \param Decl The declaration (or definition) of a function, type, or
  820. /// variable.
  821. /// \param File File where the declaration is located.
  822. /// \param Line Line number of the declaration.
  823. /// \param Elements Renamed elements.
  824. DIImportedEntity *createImportedDeclaration(DIScope *Context, DINode *Decl,
  825. DIFile *File, unsigned Line,
  826. StringRef Name = "",
  827. DINodeArray Elements = nullptr);
  828. /// Insert a new llvm.dbg.declare intrinsic call.
  829. /// \param Storage llvm::Value of the variable
  830. /// \param VarInfo Variable's debug info descriptor.
  831. /// \param Expr A complex location expression.
  832. /// \param DL Debug info location.
  833. /// \param InsertAtEnd Location for the new intrinsic.
  834. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  835. DIExpression *Expr, const DILocation *DL,
  836. BasicBlock *InsertAtEnd);
  837. /// Insert a new llvm.dbg.assign intrinsic call.
  838. /// \param LinkedInstr Instruction with a DIAssignID to link with the new
  839. /// intrinsic. The intrinsic will be inserted after
  840. /// this instruction.
  841. /// \param Val The value component of this dbg.assign.
  842. /// \param SrcVar Variable's debug info descriptor.
  843. /// \param ValExpr A complex location expression to modify \p Val.
  844. /// \param Addr The address component (store destination).
  845. /// \param AddrExpr A complex location expression to modify \p Addr.
  846. /// NOTE: \p ValExpr carries the FragInfo for the
  847. /// variable.
  848. /// \param DL Debug info location, usually: (line: 0,
  849. /// column: 0, scope: var-decl-scope). See
  850. /// getDebugValueLoc.
  851. DbgAssignIntrinsic *insertDbgAssign(Instruction *LinkedInstr, Value *Val,
  852. DILocalVariable *SrcVar,
  853. DIExpression *ValExpr, Value *Addr,
  854. DIExpression *AddrExpr,
  855. const DILocation *DL);
  856. /// Insert a new llvm.dbg.declare intrinsic call.
  857. /// \param Storage llvm::Value of the variable
  858. /// \param VarInfo Variable's debug info descriptor.
  859. /// \param Expr A complex location expression.
  860. /// \param DL Debug info location.
  861. /// \param InsertBefore Location for the new intrinsic.
  862. Instruction *insertDeclare(llvm::Value *Storage, DILocalVariable *VarInfo,
  863. DIExpression *Expr, const DILocation *DL,
  864. Instruction *InsertBefore);
  865. /// Insert a new llvm.dbg.label intrinsic call.
  866. /// \param LabelInfo Label's debug info descriptor.
  867. /// \param DL Debug info location.
  868. /// \param InsertBefore Location for the new intrinsic.
  869. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  870. Instruction *InsertBefore);
  871. /// Insert a new llvm.dbg.label intrinsic call.
  872. /// \param LabelInfo Label's debug info descriptor.
  873. /// \param DL Debug info location.
  874. /// \param InsertAtEnd Location for the new intrinsic.
  875. Instruction *insertLabel(DILabel *LabelInfo, const DILocation *DL,
  876. BasicBlock *InsertAtEnd);
  877. /// Insert a new llvm.dbg.value intrinsic call.
  878. /// \param Val llvm::Value of the variable
  879. /// \param VarInfo Variable's debug info descriptor.
  880. /// \param Expr A complex location expression.
  881. /// \param DL Debug info location.
  882. /// \param InsertAtEnd Location for the new intrinsic.
  883. Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
  884. DILocalVariable *VarInfo,
  885. DIExpression *Expr,
  886. const DILocation *DL,
  887. BasicBlock *InsertAtEnd);
  888. /// Insert a new llvm.dbg.value intrinsic call.
  889. /// \param Val llvm::Value of the variable
  890. /// \param VarInfo Variable's debug info descriptor.
  891. /// \param Expr A complex location expression.
  892. /// \param DL Debug info location.
  893. /// \param InsertBefore Location for the new intrinsic.
  894. Instruction *insertDbgValueIntrinsic(llvm::Value *Val,
  895. DILocalVariable *VarInfo,
  896. DIExpression *Expr,
  897. const DILocation *DL,
  898. Instruction *InsertBefore);
  899. /// Insert a new llvm.dbg.addr intrinsic call.
  900. /// \param Addr llvm::Value of the address
  901. /// \param VarInfo Variable's debug info descriptor.
  902. /// \param Expr A complex location expression.
  903. /// \param DL Debug info location.
  904. /// \param InsertAtEnd Location for the new intrinsic.
  905. Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr,
  906. DILocalVariable *VarInfo,
  907. DIExpression *Expr,
  908. const DILocation *DL,
  909. BasicBlock *InsertAtEnd);
  910. /// Insert a new llvm.dbg.addr intrinsic call.
  911. /// \param Addr llvm::Value of the address.
  912. /// \param VarInfo Variable's debug info descriptor.
  913. /// \param Expr A complex location expression.
  914. /// \param DL Debug info location.
  915. /// \param InsertBefore Location for the new intrinsic.
  916. Instruction *insertDbgAddrIntrinsic(llvm::Value *Addr,
  917. DILocalVariable *VarInfo,
  918. DIExpression *Expr,
  919. const DILocation *DL,
  920. Instruction *InsertBefore);
  921. /// Replace the vtable holder in the given type.
  922. ///
  923. /// If this creates a self reference, it may orphan some unresolved cycles
  924. /// in the operands of \c T, so \a DIBuilder needs to track that.
  925. void replaceVTableHolder(DICompositeType *&T,
  926. DIType *VTableHolder);
  927. /// Replace arrays on a composite type.
  928. ///
  929. /// If \c T is resolved, but the arrays aren't -- which can happen if \c T
  930. /// has a self-reference -- \a DIBuilder needs to track the array to
  931. /// resolve cycles.
  932. void replaceArrays(DICompositeType *&T, DINodeArray Elements,
  933. DINodeArray TParams = DINodeArray());
  934. /// Replace a temporary node.
  935. ///
  936. /// Call \a MDNode::replaceAllUsesWith() on \c N, replacing it with \c
  937. /// Replacement.
  938. ///
  939. /// If \c Replacement is the same as \c N.get(), instead call \a
  940. /// MDNode::replaceWithUniqued(). In this case, the uniqued node could
  941. /// have a different address, so we return the final address.
  942. template <class NodeTy>
  943. NodeTy *replaceTemporary(TempMDNode &&N, NodeTy *Replacement) {
  944. if (N.get() == Replacement)
  945. return cast<NodeTy>(MDNode::replaceWithUniqued(std::move(N)));
  946. N->replaceAllUsesWith(Replacement);
  947. return Replacement;
  948. }
  949. };
  950. // Create wrappers for C Binding types (see CBindingWrapping.h).
  951. DEFINE_ISA_CONVERSION_FUNCTIONS(DIBuilder, LLVMDIBuilderRef)
  952. } // end namespace llvm
  953. #endif // LLVM_IR_DIBUILDER_H
  954. #ifdef __GNUC__
  955. #pragma GCC diagnostic pop
  956. #endif