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; }
68 unsigned getVersion() const {
69 return getUnsignedField(0) & LLVMDebugVersionMask;
72 unsigned getTag() const {
73 return getUnsignedField(0) & ~LLVMDebugVersionMask;
76 /// ValidDebugInfo - Return true if N represents valid debug info value.
77 static bool ValidDebugInfo(MDNode *N, unsigned OptLevel);
79 /// print - print descriptor.
80 void print(raw_ostream &OS) const;
82 /// dump - print descriptor to dbgs() with a newline.
85 bool isDerivedType() const;
86 bool isCompositeType() const;
87 bool isBasicType() const;
88 bool isVariable() const;
89 bool isSubprogram() const;
90 bool isGlobalVariable() const;
93 bool isCompileUnit() const;
94 bool isNameSpace() const;
95 bool isLexicalBlock() const;
96 bool isSubrange() const;
97 bool isEnumerator() const;
99 bool isGlobal() const;
102 /// DISubrange - This is used to represent ranges, for array bounds.
103 class DISubrange : public DIDescriptor {
105 explicit DISubrange(MDNode *N = 0) : DIDescriptor(N) {}
107 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
108 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
111 /// DIArray - This descriptor holds an array of descriptors.
112 class DIArray : public DIDescriptor {
114 explicit DIArray(MDNode *N = 0)
117 unsigned getNumElements() const;
118 DIDescriptor getElement(unsigned Idx) const {
119 return getDescriptorField(Idx);
123 /// DIScope - A base class for various scopes.
124 class DIScope : public DIDescriptor {
126 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {}
127 virtual ~DIScope() {}
129 StringRef getFilename() const;
130 StringRef getDirectory() const;
133 /// DICompileUnit - A wrapper for a compile unit.
134 class DICompileUnit : public DIScope {
136 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {}
138 unsigned getLanguage() const { return getUnsignedField(2); }
139 StringRef getFilename() const { return getStringField(3); }
140 StringRef getDirectory() const { return getStringField(4); }
141 StringRef getProducer() const { return getStringField(5); }
143 /// isMain - Each input file is encoded as a separate compile unit in LLVM
144 /// debugging information output. However, many target specific tool chains
145 /// prefer to encode only one compile unit in an object file. In this
146 /// situation, the LLVM code generator will include debugging information
147 /// entities in the compile unit that is marked as main compile unit. The
148 /// code generator accepts maximum one main compile unit per module. If a
149 /// module does not contain any main compile unit then the code generator
150 /// will emit multiple compile units in the output object file.
152 bool isMain() const { return getUnsignedField(6); }
153 bool isOptimized() const { return getUnsignedField(7); }
154 StringRef getFlags() const { return getStringField(8); }
155 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
157 /// Verify - Verify that a compile unit is well formed.
160 /// print - print compile unit.
161 void print(raw_ostream &OS) const;
163 /// dump - print compile unit to dbgs() with a newline.
167 /// DIFile - This is a wrapper for a file.
168 class DIFile : public DIScope {
170 explicit DIFile(MDNode *N = 0) : DIScope(N) {
171 if (DbgNode && !isFile())
174 StringRef getFilename() const { return getStringField(1); }
175 StringRef getDirectory() const { return getStringField(2); }
176 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
179 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
180 /// FIXME: it seems strange that this doesn't have either a reference to the
181 /// type/precision or a file/line pair for location info.
182 class DIEnumerator : public DIDescriptor {
184 explicit DIEnumerator(MDNode *N = 0) : DIDescriptor(N) {}
186 StringRef getName() const { return getStringField(1); }
187 uint64_t getEnumValue() const { return getUInt64Field(2); }
190 /// DIType - This is a wrapper for a type.
191 /// FIXME: Types should be factored much better so that CV qualifiers and
192 /// others do not require a huge and empty descriptor full of zeros.
193 class DIType : public DIScope {
196 FlagPrivate = 1 << 0,
197 FlagProtected = 1 << 1,
198 FlagFwdDecl = 1 << 2,
199 FlagAppleBlock = 1 << 3,
200 FlagBlockByrefStruct = 1 << 4,
201 FlagVirtual = 1 << 5,
202 FlagArtificial = 1 << 6 // To identify artificial arguments in
203 // a subroutine type. e.g. "this" in c++.
207 // This ctor is used when the Tag has already been validated by a derived
209 DIType(MDNode *N, bool, bool) : DIScope(N) {}
213 /// Verify - Verify that a type descriptor is well formed.
216 explicit DIType(MDNode *N);
220 DIScope getContext() const { return getFieldAs<DIScope>(1); }
221 StringRef getName() const { return getStringField(2); }
222 DICompileUnit getCompileUnit() const{
223 if (getVersion() == llvm::LLVMDebugVersion7)
224 return getFieldAs<DICompileUnit>(3);
226 DIFile F = getFieldAs<DIFile>(3);
227 return F.getCompileUnit();
229 unsigned getLineNumber() const { return getUnsignedField(4); }
230 uint64_t getSizeInBits() const { return getUInt64Field(5); }
231 uint64_t getAlignInBits() const { return getUInt64Field(6); }
232 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
233 // carry this is just plain insane.
234 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
235 unsigned getFlags() const { return getUnsignedField(8); }
236 bool isPrivate() const {
237 return (getFlags() & FlagPrivate) != 0;
239 bool isProtected() const {
240 return (getFlags() & FlagProtected) != 0;
242 bool isForwardDecl() const {
243 return (getFlags() & FlagFwdDecl) != 0;
245 // isAppleBlock - Return true if this is the Apple Blocks extension.
246 bool isAppleBlockExtension() const {
247 return (getFlags() & FlagAppleBlock) != 0;
249 bool isBlockByrefStruct() const {
250 return (getFlags() & FlagBlockByrefStruct) != 0;
252 bool isVirtual() const {
253 return (getFlags() & FlagVirtual) != 0;
255 bool isArtificial() const {
256 return (getFlags() & FlagArtificial) != 0;
258 bool isValid() const {
259 return DbgNode && (isBasicType() || isDerivedType() || isCompositeType());
261 StringRef getFilename() const { return getCompileUnit().getFilename();}
262 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
264 /// print - print type.
265 void print(raw_ostream &OS) const;
267 /// dump - print type to dbgs() with a newline.
271 /// DIBasicType - A basic type, like 'int' or 'float'.
272 class DIBasicType : public DIType {
274 explicit DIBasicType(MDNode *N = 0) : DIType(N) {}
276 unsigned getEncoding() const { return getUnsignedField(9); }
278 /// print - print basic type.
279 void print(raw_ostream &OS) const;
281 /// dump - print basic type to dbgs() with a newline.
285 /// DIDerivedType - A simple derived type, like a const qualified type,
286 /// a typedef, a pointer or reference, etc.
287 class DIDerivedType : public DIType {
289 explicit DIDerivedType(MDNode *N, bool, bool)
290 : DIType(N, true, true) {}
292 explicit DIDerivedType(MDNode *N = 0)
293 : DIType(N, true, true) {}
295 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
297 /// getOriginalTypeSize - If this type is derived from a base type then
298 /// return base type size.
299 uint64_t getOriginalTypeSize() const;
301 /// print - print derived type.
302 void print(raw_ostream &OS) const;
304 /// dump - print derived type to dbgs() with a newline.
307 /// replaceAllUsesWith - Replace all uses of debug info referenced by
308 /// this descriptor. After this completes, the current debug info value
310 void replaceAllUsesWith(DIDescriptor &D);
313 /// DICompositeType - This descriptor holds a type that can refer to multiple
314 /// other types, like a function or struct.
315 /// FIXME: Why is this a DIDerivedType??
316 class DICompositeType : public DIDerivedType {
318 explicit DICompositeType(MDNode *N = 0)
319 : DIDerivedType(N, true, true) {
320 if (N && !isCompositeType())
324 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
325 unsigned getRunTimeLang() const { return getUnsignedField(11); }
326 DICompositeType getContainingType() const {
327 return getFieldAs<DICompositeType>(12);
330 /// Verify - Verify that a composite type descriptor is well formed.
333 /// print - print composite type.
334 void print(raw_ostream &OS) const;
336 /// dump - print composite type to dbgs() with a newline.
340 /// DIGlobal - This is a common class for global variables and subprograms.
341 class DIGlobal : public DIDescriptor {
343 explicit DIGlobal(MDNode *N) : DIDescriptor(N) {}
346 virtual ~DIGlobal() {}
348 DIScope getContext() const { return getFieldAs<DIScope>(2); }
349 StringRef getName() const { return getStringField(3); }
350 StringRef getDisplayName() const { return getStringField(4); }
351 StringRef getLinkageName() const { return getStringField(5); }
352 DICompileUnit getCompileUnit() const{
353 if (getVersion() == llvm::LLVMDebugVersion7)
354 return getFieldAs<DICompileUnit>(6);
356 DIFile F = getFieldAs<DIFile>(6);
357 return F.getCompileUnit();
360 unsigned getLineNumber() const { return getUnsignedField(7); }
361 DIType getType() const { return getFieldAs<DIType>(8); }
363 /// isLocalToUnit - Return true if this subprogram is local to the current
364 /// compile unit, like 'static' in C.
365 unsigned isLocalToUnit() const { return getUnsignedField(9); }
366 unsigned isDefinition() const { return getUnsignedField(10); }
368 /// print - print global.
369 void print(raw_ostream &OS) const;
371 /// dump - print global to dbgs() with a newline.
375 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
376 class DISubprogram : public DIScope {
378 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {}
380 DIScope getContext() const { return getFieldAs<DIScope>(2); }
381 StringRef getName() const { return getStringField(3); }
382 StringRef getDisplayName() const { return getStringField(4); }
383 StringRef getLinkageName() const { return getStringField(5); }
384 DICompileUnit getCompileUnit() const{
385 if (getVersion() == llvm::LLVMDebugVersion7)
386 return getFieldAs<DICompileUnit>(6);
388 DIFile F = getFieldAs<DIFile>(6);
389 return F.getCompileUnit();
391 unsigned getLineNumber() const { return getUnsignedField(7); }
392 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
394 /// getReturnTypeName - Subprogram return types are encoded either as
395 /// DIType or as DICompositeType.
396 StringRef getReturnTypeName() const {
397 DICompositeType DCT(getFieldAs<DICompositeType>(8));
399 DIArray A = DCT.getTypeArray();
400 DIType T(A.getElement(0).getNode());
403 DIType T(getFieldAs<DIType>(8));
407 /// isLocalToUnit - Return true if this subprogram is local to the current
408 /// compile unit, like 'static' in C.
409 unsigned isLocalToUnit() const { return getUnsignedField(9); }
410 unsigned isDefinition() const { return getUnsignedField(10); }
412 unsigned getVirtuality() const { return getUnsignedField(11); }
413 unsigned getVirtualIndex() const { return getUnsignedField(12); }
415 DICompositeType getContainingType() const {
416 return getFieldAs<DICompositeType>(13);
418 unsigned isArtificial() const { return getUnsignedField(14); }
419 unsigned isOptimized() const;
421 StringRef getFilename() const {
422 if (getVersion() == llvm::LLVMDebugVersion7)
423 return getCompileUnit().getFilename();
425 DIFile F = getFieldAs<DIFile>(6);
426 return F.getFilename();
429 StringRef getDirectory() const {
430 if (getVersion() == llvm::LLVMDebugVersion7)
431 return getCompileUnit().getFilename();
433 DIFile F = getFieldAs<DIFile>(6);
434 return F.getDirectory();
437 /// Verify - Verify that a subprogram descriptor is well formed.
440 /// print - print subprogram.
441 void print(raw_ostream &OS) const;
443 /// dump - print subprogram to dbgs() with a newline.
446 /// describes - Return true if this subprogram provides debugging
447 /// information for the function F.
448 bool describes(const Function *F);
451 /// DIGlobalVariable - This is a wrapper for a global variable.
452 class DIGlobalVariable : public DIGlobal {
454 explicit DIGlobalVariable(MDNode *N = 0) : DIGlobal(N) {}
456 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
458 /// Verify - Verify that a global variable descriptor is well formed.
461 /// print - print global variable.
462 void print(raw_ostream &OS) const;
464 /// dump - print global variable to dbgs() with a newline.
468 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
470 class DIVariable : public DIDescriptor {
472 explicit DIVariable(MDNode *N = 0)
475 DIScope getContext() const { return getFieldAs<DIScope>(1); }
476 StringRef getName() const { return getStringField(2); }
477 DICompileUnit getCompileUnit() const{
478 if (getVersion() == llvm::LLVMDebugVersion7)
479 return getFieldAs<DICompileUnit>(3);
481 DIFile F = getFieldAs<DIFile>(3);
482 return F.getCompileUnit();
484 unsigned getLineNumber() const { return getUnsignedField(4); }
485 DIType getType() const { return getFieldAs<DIType>(5); }
488 /// Verify - Verify that a variable descriptor is well formed.
491 /// HasComplexAddr - Return true if the variable has a complex address.
492 bool hasComplexAddress() const {
493 return getNumAddrElements() > 0;
496 unsigned getNumAddrElements() const;
498 uint64_t getAddrElement(unsigned Idx) const {
499 return getUInt64Field(Idx+6);
502 /// isBlockByrefVariable - Return true if the variable was declared as
503 /// a "__block" variable (Apple Blocks).
504 bool isBlockByrefVariable() const {
505 return getType().isBlockByrefStruct();
508 /// isInlinedFnArgument - Return trule if this variable provides debugging
509 /// information for an inlined function arguments.
510 bool isInlinedFnArgument(const Function *CurFn);
512 /// print - print variable.
513 void print(raw_ostream &OS) const;
515 /// dump - print variable to dbgs() with a newline.
519 /// DILexicalBlock - This is a wrapper for a lexical block.
520 class DILexicalBlock : public DIScope {
522 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {}
523 DIScope getContext() const { return getFieldAs<DIScope>(1); }
524 StringRef getDirectory() const { return getContext().getDirectory(); }
525 StringRef getFilename() const { return getContext().getFilename(); }
526 unsigned getLineNumber() const { return getUnsignedField(2); }
527 unsigned getColumnNumber() const { return getUnsignedField(3); }
530 /// DINameSpace - A wrapper for a C++ style name space.
531 class DINameSpace : public DIScope {
533 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {}
534 DIScope getContext() const { return getFieldAs<DIScope>(1); }
535 StringRef getName() const { return getStringField(2); }
536 StringRef getDirectory() const { return getContext().getDirectory(); }
537 StringRef getFilename() const { return getContext().getFilename(); }
538 DICompileUnit getCompileUnit() const{
539 if (getVersion() == llvm::LLVMDebugVersion7)
540 return getFieldAs<DICompileUnit>(3);
542 DIFile F = getFieldAs<DIFile>(3);
543 return F.getCompileUnit();
545 unsigned getLineNumber() const { return getUnsignedField(4); }
548 /// DILocation - This object holds location information. This object
549 /// is not associated with any DWARF tag.
550 class DILocation : public DIDescriptor {
552 explicit DILocation(MDNode *N) : DIDescriptor(N) { }
554 unsigned getLineNumber() const { return getUnsignedField(0); }
555 unsigned getColumnNumber() const { return getUnsignedField(1); }
556 DIScope getScope() const { return getFieldAs<DIScope>(2); }
557 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
558 StringRef getFilename() const { return getScope().getFilename(); }
559 StringRef getDirectory() const { return getScope().getDirectory(); }
563 /// DIFactory - This object assists with the construction of the various
567 LLVMContext& VMContext;
569 Function *DeclareFn; // llvm.dbg.declare
570 Function *ValueFn; // llvm.dbg.value
572 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
573 void operator=(const DIFactory&); // DO NOT IMPLEMENT
575 enum ComplexAddrKind { OpPlus=1, OpDeref };
577 explicit DIFactory(Module &m);
579 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
580 /// This implicitly uniques the arrays created.
581 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
583 /// GetOrCreateSubrange - Create a descriptor for a value range. This
584 /// implicitly uniques the values returned.
585 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
587 /// CreateCompileUnit - Create a new descriptor for the specified compile
589 DICompileUnit CreateCompileUnit(unsigned LangID,
594 bool isOptimized = false,
595 StringRef Flags = "",
596 unsigned RunTimeVer = 0);
598 /// CreateFile - Create a new descriptor for the specified file.
599 DIFile CreateFile(StringRef Filename, StringRef Directory, DICompileUnit CU);
601 /// CreateEnumerator - Create a single enumerator value.
602 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
604 /// CreateBasicType - Create a basic type like int, float, etc.
605 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
606 DIFile F, unsigned LineNumber,
607 uint64_t SizeInBits, uint64_t AlignInBits,
608 uint64_t OffsetInBits, unsigned Flags,
611 /// CreateBasicType - Create a basic type like int, float, etc.
612 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
613 DIFile F, unsigned LineNumber,
614 Constant *SizeInBits, Constant *AlignInBits,
615 Constant *OffsetInBits, unsigned Flags,
618 /// CreateDerivedType - Create a derived type like const qualified type,
619 /// pointer, typedef, etc.
620 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
624 uint64_t SizeInBits, uint64_t AlignInBits,
625 uint64_t OffsetInBits, unsigned Flags,
628 /// CreateDerivedType - Create a derived type like const qualified type,
629 /// pointer, typedef, etc.
630 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
634 Constant *SizeInBits,
635 Constant *AlignInBits,
636 Constant *OffsetInBits, unsigned Flags,
639 /// CreateCompositeType - Create a composite type like array, struct, etc.
640 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
645 uint64_t AlignInBits,
646 uint64_t OffsetInBits, unsigned Flags,
649 unsigned RunTimeLang = 0,
650 MDNode *ContainingType = 0);
652 /// CreateArtificialType - Create a new DIType with "artificial" flag set.
653 DIType CreateArtificialType(DIType Ty);
655 /// CreateCompositeType - Create a composite type like array, struct, etc.
656 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
660 Constant *SizeInBits,
661 Constant *AlignInBits,
662 Constant *OffsetInBits,
666 unsigned RunTimeLang = 0);
668 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
669 /// See comments in DISubprogram for descriptions of these fields.
670 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
671 StringRef DisplayName,
672 StringRef LinkageName,
673 DIFile F, unsigned LineNo,
674 DIType Ty, bool isLocalToUnit,
679 bool isArtificial = 0,
680 bool isOptimized = false);
682 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
683 /// given declaration.
684 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
686 /// CreateGlobalVariable - Create a new descriptor for the specified global.
688 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
689 StringRef DisplayName,
690 StringRef LinkageName,
692 unsigned LineNo, DIType Ty, bool isLocalToUnit,
693 bool isDefinition, llvm::GlobalVariable *GV);
695 /// CreateVariable - Create a new descriptor for the specified variable.
696 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
698 DIFile F, unsigned LineNo,
701 /// CreateComplexVariable - Create a new descriptor for the specified
702 /// variable which has a complex address expression for its address.
703 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
704 const std::string &Name,
705 DIFile F, unsigned LineNo,
707 SmallVector<Value *, 9> &addr);
709 /// CreateLexicalBlock - This creates a descriptor for a lexical block
710 /// with the specified parent context.
711 DILexicalBlock CreateLexicalBlock(DIDescriptor Context, unsigned Line = 0,
714 /// CreateNameSpace - This creates new descriptor for a namespace
715 /// with the specified parent context.
716 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
717 DIFile F, unsigned LineNo);
719 /// CreateLocation - Creates a debug info location.
720 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
721 DIScope S, DILocation OrigLoc);
723 /// CreateLocation - Creates a debug info location.
724 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
725 DIScope S, MDNode *OrigLoc = 0);
727 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
728 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
729 BasicBlock *InsertAtEnd);
731 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
732 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
733 Instruction *InsertBefore);
735 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
736 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
737 DIVariable D, BasicBlock *InsertAtEnd);
739 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
740 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, uint64_t Offset,
741 DIVariable D, Instruction *InsertBefore);
743 Constant *GetTagConstant(unsigned TAG);
746 bool getLocationInfo(const Value *V, std::string &DisplayName,
747 std::string &Type, unsigned &LineNo, std::string &File,
750 /// getDISubprogram - Find subprogram that is enclosing this scope.
751 DISubprogram getDISubprogram(MDNode *Scope);
753 /// getDICompositeType - Find underlying composite type.
754 DICompositeType getDICompositeType(DIType T);
756 class DebugInfoFinder {
758 /// processModule - Process entire module and collect debug info
760 void processModule(Module &M);
763 /// processType - Process DIType.
764 void processType(DIType DT);
766 /// processLexicalBlock - Process DILexicalBlock.
767 void processLexicalBlock(DILexicalBlock LB);
769 /// processSubprogram - Process DISubprogram.
770 void processSubprogram(DISubprogram SP);
772 /// processDeclare - Process DbgDeclareInst.
773 void processDeclare(DbgDeclareInst *DDI);
775 /// processLocation - Process DILocation.
776 void processLocation(DILocation Loc);
778 /// addCompileUnit - Add compile unit into CUs.
779 bool addCompileUnit(DICompileUnit CU);
781 /// addGlobalVariable - Add global variable into GVs.
782 bool addGlobalVariable(DIGlobalVariable DIG);
784 // addSubprogram - Add subprgoram into SPs.
785 bool addSubprogram(DISubprogram SP);
787 /// addType - Add type into Tys.
788 bool addType(DIType DT);
791 typedef SmallVector<MDNode *, 8>::const_iterator iterator;
792 iterator compile_unit_begin() const { return CUs.begin(); }
793 iterator compile_unit_end() const { return CUs.end(); }
794 iterator subprogram_begin() const { return SPs.begin(); }
795 iterator subprogram_end() const { return SPs.end(); }
796 iterator global_variable_begin() const { return GVs.begin(); }
797 iterator global_variable_end() const { return GVs.end(); }
798 iterator type_begin() const { return TYs.begin(); }
799 iterator type_end() const { return TYs.end(); }
801 unsigned compile_unit_count() const { return CUs.size(); }
802 unsigned global_variable_count() const { return GVs.size(); }
803 unsigned subprogram_count() const { return SPs.size(); }
804 unsigned type_count() const { return TYs.size(); }
807 SmallVector<MDNode *, 8> CUs; // Compile Units
808 SmallVector<MDNode *, 8> SPs; // Subprograms
809 SmallVector<MDNode *, 8> GVs; // Global Variables;
810 SmallVector<MDNode *, 8> TYs; // Types
811 SmallPtrSet<MDNode *, 64> NodesSeen;
813 } // end namespace llvm