1 //===--- llvm/Analysis/DebugInfo.h - Debug Information Helpers --*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines a bunch of datatypes that are useful for creating and
11 // walking debug info in LLVM IR form. They essentially provide wrappers around
12 // the information in the global variables that's needed when constructing the
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_ANALYSIS_DEBUGINFO_H
18 #define LLVM_ANALYSIS_DEBUGINFO_H
20 #include "llvm/ADT/SmallVector.h"
21 #include "llvm/ADT/SmallPtrSet.h"
22 #include "llvm/ADT/StringRef.h"
23 #include "llvm/Support/Dwarf.h"
39 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info.
40 /// This should not be stored in a container, because underly MDNode may
41 /// change in certain situations.
46 StringRef getStringField(unsigned Elt) const;
47 unsigned getUnsignedField(unsigned Elt) const {
48 return (unsigned)getUInt64Field(Elt);
50 uint64_t getUInt64Field(unsigned Elt) const;
51 DIDescriptor getDescriptorField(unsigned Elt) const;
53 template <typename DescTy>
54 DescTy getFieldAs(unsigned Elt) const {
55 return DescTy(getDescriptorField(Elt).getNode());
58 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
61 explicit DIDescriptor() : DbgNode(0) {}
62 explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
64 bool Verify() const { return DbgNode != 0; }
66 MDNode *getNode() const { return DbgNode; }
67 operator MDNode *() const { return DbgNode; }
68 MDNode *operator ->() const { return DbgNode; }
70 unsigned getVersion() const {
71 return getUnsignedField(0) & LLVMDebugVersionMask;
74 unsigned getTag() const {
75 return getUnsignedField(0) & ~LLVMDebugVersionMask;
78 /// ValidDebugInfo - Return true if N represents valid debug info value.
79 static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
81 /// print - print descriptor.
82 void print(raw_ostream &OS) const;
84 /// dump - print descriptor to dbgs() with a newline.
87 bool isDerivedType() const;
88 bool isCompositeType() const;
89 bool isBasicType() const;
90 bool isVariable() const;
91 bool isSubprogram() const;
92 bool isGlobalVariable() const;
95 bool isCompileUnit() const;
96 bool isNameSpace() const;
97 bool isLexicalBlock() const;
98 bool isSubrange() const;
99 bool isEnumerator() const;
101 bool isGlobal() const;
104 /// DISubrange - This is used to represent ranges, for array bounds.
105 class DISubrange : public DIDescriptor {
107 explicit DISubrange(MDNode *N = 0) : DIDescriptor(N) {}
109 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
110 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
113 /// DIArray - This descriptor holds an array of descriptors.
114 class DIArray : public DIDescriptor {
116 explicit DIArray(MDNode *N = 0)
119 unsigned getNumElements() const;
120 DIDescriptor getElement(unsigned Idx) const {
121 return getDescriptorField(Idx);
125 /// DIScope - A base class for various scopes.
126 class DIScope : public DIDescriptor {
128 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {}
129 virtual ~DIScope() {}
131 StringRef getFilename() const;
132 StringRef getDirectory() const;
135 /// DICompileUnit - A wrapper for a compile unit.
136 class DICompileUnit : public DIScope {
138 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {}
140 unsigned getLanguage() const { return getUnsignedField(2); }
141 StringRef getFilename() const { return getStringField(3); }
142 StringRef getDirectory() const { return getStringField(4); }
143 StringRef getProducer() const { return getStringField(5); }
145 /// isMain - Each input file is encoded as a separate compile unit in LLVM
146 /// debugging information output. However, many target specific tool chains
147 /// prefer to encode only one compile unit in an object file. In this
148 /// situation, the LLVM code generator will include debugging information
149 /// entities in the compile unit that is marked as main compile unit. The
150 /// code generator accepts maximum one main compile unit per module. If a
151 /// module does not contain any main compile unit then the code generator
152 /// will emit multiple compile units in the output object file.
154 bool isMain() const { return getUnsignedField(6); }
155 bool isOptimized() const { return getUnsignedField(7); }
156 StringRef getFlags() const { return getStringField(8); }
157 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
159 /// Verify - Verify that a compile unit is well formed.
162 /// print - print compile unit.
163 void print(raw_ostream &OS) const;
165 /// dump - print compile unit to dbgs() with a newline.
169 /// DIFile - This is a wrapper for a file.
170 class DIFile : public DIScope {
172 explicit DIFile(MDNode *N = 0) : DIScope(N) {
173 if (DbgNode && !isFile())
176 StringRef getFilename() const { return getStringField(1); }
177 StringRef getDirectory() const { return getStringField(2); }
178 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
181 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
182 /// FIXME: it seems strange that this doesn't have either a reference to the
183 /// type/precision or a file/line pair for location info.
184 class DIEnumerator : public DIDescriptor {
186 explicit DIEnumerator(MDNode *N = 0) : DIDescriptor(N) {}
188 StringRef getName() const { return getStringField(1); }
189 uint64_t getEnumValue() const { return getUInt64Field(2); }
192 /// DIType - This is a wrapper for a type.
193 /// FIXME: Types should be factored much better so that CV qualifiers and
194 /// others do not require a huge and empty descriptor full of zeros.
195 class DIType : public DIScope {
198 FlagPrivate = 1 << 0,
199 FlagProtected = 1 << 1,
200 FlagFwdDecl = 1 << 2,
201 FlagAppleBlock = 1 << 3,
202 FlagBlockByrefStruct = 1 << 4,
203 FlagVirtual = 1 << 5,
204 FlagArtificial = 1 << 6 // To identify artificial arguments in
205 // a subroutine type. e.g. "this" in c++.
209 // This ctor is used when the Tag has already been validated by a derived
211 DIType(MDNode *N, bool, bool) : DIScope(N) {}
215 /// Verify - Verify that a type descriptor is well formed.
218 explicit DIType(MDNode *N);
222 DIScope getContext() const { return getFieldAs<DIScope>(1); }
223 StringRef getName() const { return getStringField(2); }
224 DICompileUnit getCompileUnit() const{
225 if (getVersion() == llvm::LLVMDebugVersion7)
226 return getFieldAs<DICompileUnit>(3);
228 DIFile F = getFieldAs<DIFile>(3);
229 return F.getCompileUnit();
231 unsigned getLineNumber() const { return getUnsignedField(4); }
232 uint64_t getSizeInBits() const { return getUInt64Field(5); }
233 uint64_t getAlignInBits() const { return getUInt64Field(6); }
234 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
235 // carry this is just plain insane.
236 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
237 unsigned getFlags() const { return getUnsignedField(8); }
238 bool isPrivate() const {
239 return (getFlags() & FlagPrivate) != 0;
241 bool isProtected() const {
242 return (getFlags() & FlagProtected) != 0;
244 bool isForwardDecl() const {
245 return (getFlags() & FlagFwdDecl) != 0;
247 // isAppleBlock - Return true if this is the Apple Blocks extension.
248 bool isAppleBlockExtension() const {
249 return (getFlags() & FlagAppleBlock) != 0;
251 bool isBlockByrefStruct() const {
252 return (getFlags() & FlagBlockByrefStruct) != 0;
254 bool isVirtual() const {
255 return (getFlags() & FlagVirtual) != 0;
257 bool isArtificial() const {
258 return (getFlags() & FlagArtificial) != 0;
260 bool isValid() const {
261 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
263 StringRef getFilename() const { return getCompileUnit().getFilename();}
264 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
266 /// print - print type.
267 void print(raw_ostream &OS) const;
269 /// dump - print type to dbgs() with a newline.
273 /// DIBasicType - A basic type, like 'int' or 'float'.
274 class DIBasicType : public DIType {
276 explicit DIBasicType(MDNode *N = 0) : DIType(N) {}
278 unsigned getEncoding() const { return getUnsignedField(9); }
280 /// print - print basic type.
281 void print(raw_ostream &OS) const;
283 /// dump - print basic type to dbgs() with a newline.
287 /// DIDerivedType - A simple derived type, like a const qualified type,
288 /// a typedef, a pointer or reference, etc.
289 class DIDerivedType : public DIType {
291 explicit DIDerivedType(MDNode *N, bool, bool)
292 : DIType(N, true, true) {}
294 explicit DIDerivedType(MDNode *N = 0)
295 : DIType(N, true, true) {}
297 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
299 /// getOriginalTypeSize - If this type is derived from a base type then
300 /// return base type size.
301 uint64_t getOriginalTypeSize() const;
303 /// print - print derived type.
304 void print(raw_ostream &OS) const;
306 /// dump - print derived type to dbgs() with a newline.
309 /// replaceAllUsesWith - Replace all uses of debug info referenced by
310 /// this descriptor. After this completes, the current debug info value
312 void replaceAllUsesWith(DIDescriptor &D);
315 /// DICompositeType - This descriptor holds a type that can refer to multiple
316 /// other types, like a function or struct.
317 /// FIXME: Why is this a DIDerivedType??
318 class DICompositeType : public DIDerivedType {
320 explicit DICompositeType(MDNode *N = 0)
321 : DIDerivedType(N, true, true) {
322 if (N && !isCompositeType())
326 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
327 unsigned getRunTimeLang() const { return getUnsignedField(11); }
328 DICompositeType getContainingType() const {
329 return getFieldAs<DICompositeType>(12);
332 /// Verify - Verify that a composite type descriptor is well formed.
335 /// print - print composite type.
336 void print(raw_ostream &OS) const;
338 /// dump - print composite type to dbgs() with a newline.
342 /// DIGlobal - This is a common class for global variables and subprograms.
343 class DIGlobal : public DIDescriptor {
345 explicit DIGlobal(MDNode *N) : DIDescriptor(N) {}
348 virtual ~DIGlobal() {}
350 DIScope getContext() const { return getFieldAs<DIScope>(2); }
351 StringRef getName() const { return getStringField(3); }
352 StringRef getDisplayName() const { return getStringField(4); }
353 StringRef getLinkageName() const { return getStringField(5); }
354 DICompileUnit getCompileUnit() const{
355 if (getVersion() == llvm::LLVMDebugVersion7)
356 return getFieldAs<DICompileUnit>(6);
358 DIFile F = getFieldAs<DIFile>(6);
359 return F.getCompileUnit();
362 unsigned getLineNumber() const { return getUnsignedField(7); }
363 DIType getType() const { return getFieldAs<DIType>(8); }
365 /// isLocalToUnit - Return true if this subprogram is local to the current
366 /// compile unit, like 'static' in C.
367 unsigned isLocalToUnit() const { return getUnsignedField(9); }
368 unsigned isDefinition() const { return getUnsignedField(10); }
370 /// print - print global.
371 void print(raw_ostream &OS) const;
373 /// dump - print global to dbgs() with a newline.
377 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
378 class DISubprogram : public DIScope {
380 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {}
382 DIScope getContext() const { return getFieldAs<DIScope>(2); }
383 StringRef getName() const { return getStringField(3); }
384 StringRef getDisplayName() const { return getStringField(4); }
385 StringRef getLinkageName() const { return getStringField(5); }
386 DICompileUnit getCompileUnit() const{
387 if (getVersion() == llvm::LLVMDebugVersion7)
388 return getFieldAs<DICompileUnit>(6);
390 DIFile F = getFieldAs<DIFile>(6);
391 return F.getCompileUnit();
393 unsigned getLineNumber() const { return getUnsignedField(7); }
394 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
396 /// getReturnTypeName - Subprogram return types are encoded either as
397 /// DIType or as DICompositeType.
398 StringRef getReturnTypeName() const {
399 DICompositeType DCT(getFieldAs<DICompositeType>(8));
401 DIArray A = DCT.getTypeArray();
402 DIType T(A.getElement(0));
405 DIType T(getFieldAs<DIType>(8));
409 /// isLocalToUnit - Return true if this subprogram is local to the current
410 /// compile unit, like 'static' in C.
411 unsigned isLocalToUnit() const { return getUnsignedField(9); }
412 unsigned isDefinition() const { return getUnsignedField(10); }
414 unsigned getVirtuality() const { return getUnsignedField(11); }
415 unsigned getVirtualIndex() const { return getUnsignedField(12); }
417 DICompositeType getContainingType() const {
418 return getFieldAs<DICompositeType>(13);
420 unsigned isArtificial() const { return getUnsignedField(14); }
421 unsigned isOptimized() const;
423 StringRef getFilename() const {
424 if (getVersion() == llvm::LLVMDebugVersion7)
425 return getCompileUnit().getFilename();
427 DIFile F = getFieldAs<DIFile>(6);
428 return F.getFilename();
431 StringRef getDirectory() const {
432 if (getVersion() == llvm::LLVMDebugVersion7)
433 return getCompileUnit().getFilename();
435 DIFile F = getFieldAs<DIFile>(6);
436 return F.getDirectory();
439 /// Verify - Verify that a subprogram descriptor is well formed.
442 /// print - print subprogram.
443 void print(raw_ostream &OS) const;
445 /// dump - print subprogram to dbgs() with a newline.
448 /// describes - Return true if this subprogram provides debugging
449 /// information for the function F.
450 bool describes(const Function *F);
453 /// DIGlobalVariable - This is a wrapper for a global variable.
454 class DIGlobalVariable : public DIGlobal {
456 explicit DIGlobalVariable(MDNode *N = 0) : DIGlobal(N) {}
458 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
460 /// Verify - Verify that a global variable descriptor is well formed.
463 /// print - print global variable.
464 void print(raw_ostream &OS) const;
466 /// dump - print global variable to dbgs() with a newline.
470 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
472 class DIVariable : public DIDescriptor {
474 explicit DIVariable(MDNode *N = 0)
477 DIScope getContext() const { return getFieldAs<DIScope>(1); }
478 StringRef getName() const { return getStringField(2); }
479 DICompileUnit getCompileUnit() const{
480 if (getVersion() == llvm::LLVMDebugVersion7)
481 return getFieldAs<DICompileUnit>(3);
483 DIFile F = getFieldAs<DIFile>(3);
484 return F.getCompileUnit();
486 unsigned getLineNumber() const { return getUnsignedField(4); }
487 DIType getType() const { return getFieldAs<DIType>(5); }
490 /// Verify - Verify that a variable descriptor is well formed.
493 /// HasComplexAddr - Return true if the variable has a complex address.
494 bool hasComplexAddress() const {
495 return getNumAddrElements() > 0;
498 unsigned getNumAddrElements() const;
500 uint64_t getAddrElement(unsigned Idx) const {
501 return getUInt64Field(Idx+6);
504 /// isBlockByrefVariable - Return true if the variable was declared as
505 /// a "__block" variable (Apple Blocks).
506 bool isBlockByrefVariable() const {
507 return getType().isBlockByrefStruct();
510 /// isInlinedFnArgument - Return trule if this variable provides debugging
511 /// information for an inlined function arguments.
512 bool isInlinedFnArgument(const Function *CurFn);
514 /// print - print variable.
515 void print(raw_ostream &OS) const;
517 /// dump - print variable to dbgs() with a newline.
521 /// DILexicalBlock - This is a wrapper for a lexical block.
522 class DILexicalBlock : public DIScope {
524 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {}
525 DIScope getContext() const { return getFieldAs<DIScope>(1); }
526 StringRef getDirectory() const { return getContext().getDirectory(); }
527 StringRef getFilename() const { return getContext().getFilename(); }
528 unsigned getLineNumber() const { return getUnsignedField(2); }
529 unsigned getColumnNumber() const { return getUnsignedField(3); }
532 /// DINameSpace - A wrapper for a C++ style name space.
533 class DINameSpace : public DIScope {
535 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {}
536 DIScope getContext() const { return getFieldAs<DIScope>(1); }
537 StringRef getName() const { return getStringField(2); }
538 StringRef getDirectory() const { return getContext().getDirectory(); }
539 StringRef getFilename() const { return getContext().getFilename(); }
540 DICompileUnit getCompileUnit() const{
541 if (getVersion() == llvm::LLVMDebugVersion7)
542 return getFieldAs<DICompileUnit>(3);
544 DIFile F = getFieldAs<DIFile>(3);
545 return F.getCompileUnit();
547 unsigned getLineNumber() const { return getUnsignedField(4); }
550 /// DILocation - This object holds location information. This object
551 /// is not associated with any DWARF tag.
552 class DILocation : public DIDescriptor {
554 explicit DILocation(MDNode *N) : DIDescriptor(N) { }
556 unsigned getLineNumber() const { return getUnsignedField(0); }
557 unsigned getColumnNumber() const { return getUnsignedField(1); }
558 DIScope getScope() const { return getFieldAs<DIScope>(2); }
559 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
560 StringRef getFilename() const { return getScope().getFilename(); }
561 StringRef getDirectory() const { return getScope().getDirectory(); }
565 /// DIFactory - This object assists with the construction of the various
569 LLVMContext& VMContext;
571 Function *DeclareFn; // llvm.dbg.declare
572 Function *ValueFn; // llvm.dbg.value
574 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
575 void operator=(const DIFactory&); // DO NOT IMPLEMENT
577 enum ComplexAddrKind { OpPlus=1, OpDeref };
579 explicit DIFactory(Module &m);
581 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
582 /// This implicitly uniques the arrays created.
583 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
585 /// GetOrCreateSubrange - Create a descriptor for a value range. This
586 /// implicitly uniques the values returned.
587 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
589 /// CreateCompileUnit - Create a new descriptor for the specified compile
591 DICompileUnit CreateCompileUnit(unsigned LangID,
596 bool isOptimized = false,
597 StringRef Flags = "",
598 unsigned RunTimeVer = 0);
600 /// CreateFile - Create a new descriptor for the specified file.
601 DIFile CreateFile(StringRef Filename, StringRef Directory, DICompileUnit CU);
603 /// CreateEnumerator - Create a single enumerator value.
604 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
606 /// CreateBasicType - Create a basic type like int, float, etc.
607 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
608 DIFile F, unsigned LineNumber,
609 uint64_t SizeInBits, uint64_t AlignInBits,
610 uint64_t OffsetInBits, unsigned Flags,
613 /// CreateBasicType - Create a basic type like int, float, etc.
614 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
615 DIFile F, unsigned LineNumber,
616 Constant *SizeInBits, Constant *AlignInBits,
617 Constant *OffsetInBits, unsigned Flags,
620 /// CreateDerivedType - Create a derived type like const qualified type,
621 /// pointer, typedef, etc.
622 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
626 uint64_t SizeInBits, uint64_t AlignInBits,
627 uint64_t OffsetInBits, unsigned Flags,
630 /// CreateDerivedType - Create a derived type like const qualified type,
631 /// pointer, typedef, etc.
632 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
636 Constant *SizeInBits,
637 Constant *AlignInBits,
638 Constant *OffsetInBits, unsigned Flags,
641 /// CreateCompositeType - Create a composite type like array, struct, etc.
642 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
647 uint64_t AlignInBits,
648 uint64_t OffsetInBits, unsigned Flags,
651 unsigned RunTimeLang = 0,
652 MDNode *ContainingType = 0);
654 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
655 DIType CreateArtificialType(DIType Ty);
657 /// CreateCompositeType - Create a composite type like array, struct, etc.
658 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
662 Constant *SizeInBits,
663 Constant *AlignInBits,
664 Constant *OffsetInBits,
668 unsigned RunTimeLang = 0);
670 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
671 /// See comments in DISubprogram for descriptions of these fields.
672 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
673 StringRef DisplayName,
674 StringRef LinkageName,
675 DIFile F, unsigned LineNo,
676 DIType Ty, bool isLocalToUnit,
681 bool isArtificial = 0,
682 bool isOptimized = false);
684 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
685 /// given declaration.
686 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
688 /// CreateGlobalVariable - Create a new descriptor for the specified global.
690 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
691 StringRef DisplayName,
692 StringRef LinkageName,
694 unsigned LineNo, DIType Ty, bool isLocalToUnit,
695 bool isDefinition, llvm::GlobalVariable *GV);
697 /// CreateVariable - Create a new descriptor for the specified variable.
698 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
700 DIFile F, unsigned LineNo,
703 /// CreateComplexVariable - Create a new descriptor for the specified
704 /// variable which has a complex address expression for its address.
705 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
706 const std::string &Name,
707 DIFile F, unsigned LineNo,
709 SmallVector<Value *, 9> &addr);
711 /// CreateLexicalBlock - This creates a descriptor for a lexical block
712 /// with the specified parent context.
713 DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0,
716 /// CreateNameSpace - This creates new descriptor for a namespace
717 /// with the specified parent context.
718 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
719 DIFile F, unsigned LineNo);
721 /// CreateLocation - Creates a debug info location.
722 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
723 DIScope S, DILocation OrigLoc);
725 /// CreateLocation - Creates a debug info location.
726 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
727 DIScope S, MDNode *OrigLoc = 0);
729 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
730 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
731 BasicBlock *InsertAtEnd);
733 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
734 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
735 Instruction *InsertBefore);
737 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
738 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
739 DIVariable D, BasicBlock *InsertAtEnd);
741 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
742 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
743 DIVariable D, Instruction *InsertBefore);
745 Constant *GetTagConstant(unsigned TAG);
748 bool getLocationInfo(const Value *V, std::string &DisplayName,
749 std::string &Type, unsigned &LineNo, std::string &File,
752 /// getDISubprogram - Find subprogram that is enclosing this scope.
753 DISubprogram getDISubprogram(MDNode *Scope);
755 /// getDICompositeType - Find underlying composite type.
756 DICompositeType getDICompositeType(DIType T);
758 class DebugInfoFinder {
760 /// processModule - Process entire module and collect debug info
762 void processModule(Module &M);
765 /// processType - Process DIType.
766 void processType(DIType DT);
768 /// processLexicalBlock - Process DILexicalBlock.
769 void processLexicalBlock(DILexicalBlock LB);
771 /// processSubprogram - Process DISubprogram.
772 void processSubprogram(DISubprogram SP);
774 /// processDeclare - Process DbgDeclareInst.
775 void processDeclare(DbgDeclareInst *DDI);
777 /// processLocation - Process DILocation.
778 void processLocation(DILocation Loc);
780 /// addCompileUnit - Add compile unit into CUs.
781 bool addCompileUnit(DICompileUnit CU);
783 /// addGlobalVariable - Add global variable into GVs.
784 bool addGlobalVariable(DIGlobalVariable DIG);
786 // addSubprogram - Add subprgoram into SPs.
787 bool addSubprogram(DISubprogram SP);
789 /// addType - Add type into Tys.
790 bool addType(DIType DT);
793 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
794 iterator compile_unit_begin() const { return CUs.begin(); }
795 iterator compile_unit_end() const { return CUs.end(); }
796 iterator subprogram_begin() const { return SPs.begin(); }
797 iterator subprogram_end() const { return SPs.end(); }
798 iterator global_variable_begin() const { return GVs.begin(); }
799 iterator global_variable_end() const { return GVs.end(); }
800 iterator type_begin() const { return TYs.begin(); }
801 iterator type_end() const { return TYs.end(); }
803 unsigned compile_unit_count() const { return CUs.size(); }
804 unsigned global_variable_count() const { return GVs.size(); }
805 unsigned subprogram_count() const { return SPs.size(); }
806 unsigned type_count() const { return TYs.size(); }
809 SmallVector<MDNode *, 8> CUs; // Compile Units
810 SmallVector<MDNode *, 8> SPs; // Subprograms
811 SmallVector<MDNode *, 8> GVs; // Global Variables;
812 SmallVector<MDNode *, 8> TYs; // Types
813 SmallPtrSet<MDNode *, 64> NodesSeen;
815 } // end namespace llvm