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/Metadata.h"
21 #include "llvm/Target/TargetMachine.h"
22 #include "llvm/ADT/StringMap.h"
23 #include "llvm/ADT/DenseMap.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/SmallPtrSet.h"
26 #include "llvm/Support/Dwarf.h"
27 #include "llvm/Support/ValueHandle.h"
37 struct DbgStopPointInst;
38 struct DbgDeclareInst;
39 struct DbgFuncStartInst;
40 struct DbgRegionStartInst;
41 struct DbgRegionEndInst;
43 struct DebugLocTracker;
47 /// DIDescriptor - A thin wraper around MDNode to access encoded debug info. This should not
48 /// be stored in a container, because underly MDNode may change in certain situations.
53 /// DIDescriptor constructor. If the specified node is non-null, check
54 /// to make sure that the tag in the descriptor matches 'RequiredTag'. If
55 /// not, the debug info is corrupt and we ignore it.
56 DIDescriptor(MDNode *N, unsigned RequiredTag);
58 StringRef getStringField(unsigned Elt) const;
59 unsigned getUnsignedField(unsigned Elt) const {
60 return (unsigned)getUInt64Field(Elt);
62 uint64_t getUInt64Field(unsigned Elt) const;
63 DIDescriptor getDescriptorField(unsigned Elt) const;
65 template <typename DescTy>
66 DescTy getFieldAs(unsigned Elt) const {
67 return DescTy(getDescriptorField(Elt).getNode());
70 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
73 explicit DIDescriptor() : DbgNode(0) {}
74 explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
76 bool isNull() const { return DbgNode == 0; }
78 MDNode *getNode() const { return DbgNode; }
80 unsigned getVersion() const {
81 return getUnsignedField(0) & LLVMDebugVersionMask;
84 unsigned getTag() const {
85 return getUnsignedField(0) & ~LLVMDebugVersionMask;
88 /// ValidDebugInfo - Return true if N represents valid debug info value.
89 static bool ValidDebugInfo(MDNode *N, CodeGenOpt::Level OptLevel);
91 /// dump - print descriptor.
94 bool isDerivedType() const;
95 bool isCompositeType() const;
96 bool isBasicType() const;
97 bool isVariable() const;
98 bool isSubprogram() const;
99 bool isGlobalVariable() const;
100 bool isScope() const;
101 bool isCompileUnit() const;
102 bool isLexicalBlock() const;
103 bool isSubrange() const;
104 bool isEnumerator() const;
106 bool isGlobal() const;
109 /// DISubrange - This is used to represent ranges, for array bounds.
110 class DISubrange : public DIDescriptor {
112 explicit DISubrange(MDNode *N = 0)
113 : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
115 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
116 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
119 /// DIArray - This descriptor holds an array of descriptors.
120 class DIArray : public DIDescriptor {
122 explicit DIArray(MDNode *N = 0)
125 unsigned getNumElements() const;
126 DIDescriptor getElement(unsigned Idx) const {
127 return getDescriptorField(Idx);
131 /// DIScope - A base class for various scopes.
132 class DIScope : public DIDescriptor {
134 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
135 if (DbgNode && !isScope())
138 virtual ~DIScope() {}
140 StringRef getFilename() const;
141 StringRef getDirectory() const;
144 /// DICompileUnit - A wrapper for a compile unit.
145 class DICompileUnit : public DIScope {
147 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {
148 if (DbgNode && !isCompileUnit())
152 unsigned getLanguage() const { return getUnsignedField(2); }
153 StringRef getFilename() const { return getStringField(3); }
154 StringRef getDirectory() const { return getStringField(4); }
155 StringRef getProducer() const { return getStringField(5); }
157 /// isMain - Each input file is encoded as a separate compile unit in LLVM
158 /// debugging information output. However, many target specific tool chains
159 /// prefer to encode only one compile unit in an object file. In this
160 /// situation, the LLVM code generator will include debugging information
161 /// entities in the compile unit that is marked as main compile unit. The
162 /// code generator accepts maximum one main compile unit per module. If a
163 /// module does not contain any main compile unit then the code generator
164 /// will emit multiple compile units in the output object file.
166 bool isMain() const { return getUnsignedField(6); }
167 bool isOptimized() const { return getUnsignedField(7); }
168 StringRef getFlags() const { return getStringField(8); }
169 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
171 /// Verify - Verify that a compile unit is well formed.
174 /// dump - print compile unit.
178 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
179 /// FIXME: it seems strange that this doesn't have either a reference to the
180 /// type/precision or a file/line pair for location info.
181 class DIEnumerator : public DIDescriptor {
183 explicit DIEnumerator(MDNode *N = 0)
184 : DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
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 DIDescriptor {
196 FlagPrivate = 1 << 0,
197 FlagProtected = 1 << 1,
198 FlagFwdDecl = 1 << 2,
199 FlagAppleBlock = 1 << 3,
200 FlagBlockByrefStruct = 1 << 4,
205 DIType(MDNode *N, unsigned Tag)
206 : DIDescriptor(N, Tag) {}
207 // This ctor is used when the Tag has already been validated by a derived
209 DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
213 /// Verify - Verify that a type descriptor is well formed.
216 explicit DIType(MDNode *N);
220 DIDescriptor getContext() const { return getDescriptorField(1); }
221 StringRef getName() const { return getStringField(2); }
222 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
223 unsigned getLineNumber() const { return getUnsignedField(4); }
224 uint64_t getSizeInBits() const { return getUInt64Field(5); }
225 uint64_t getAlignInBits() const { return getUInt64Field(6); }
226 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
227 // carry this is just plain insane.
228 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
229 unsigned getFlags() const { return getUnsignedField(8); }
230 bool isPrivate() const {
231 return (getFlags() & FlagPrivate) != 0;
233 bool isProtected() const {
234 return (getFlags() & FlagProtected) != 0;
236 bool isForwardDecl() const {
237 return (getFlags() & FlagFwdDecl) != 0;
239 // isAppleBlock - Return true if this is the Apple Blocks extension.
240 bool isAppleBlockExtension() const {
241 return (getFlags() & FlagAppleBlock) != 0;
243 bool isBlockByrefStruct() const {
244 return (getFlags() & FlagBlockByrefStruct) != 0;
246 bool isVirtual() const {
247 return (getFlags() & FlagVirtual) != 0;
250 /// dump - print type.
254 /// DIBasicType - A basic type, like 'int' or 'float'.
255 class DIBasicType : public DIType {
257 explicit DIBasicType(MDNode *N = 0)
258 : DIType(N, dwarf::DW_TAG_base_type) {}
260 unsigned getEncoding() const { return getUnsignedField(9); }
262 /// dump - print basic type.
266 /// DIDerivedType - A simple derived type, like a const qualified type,
267 /// a typedef, a pointer or reference, etc.
268 class DIDerivedType : public DIType {
270 explicit DIDerivedType(MDNode *N, bool, bool)
271 : DIType(N, true, true) {}
273 explicit DIDerivedType(MDNode *N = 0)
274 : DIType(N, true, true) {
275 if (DbgNode && !isDerivedType())
279 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
281 /// getOriginalTypeSize - If this type is derived from a base type then
282 /// return base type size.
283 uint64_t getOriginalTypeSize() const;
284 /// dump - print derived type.
287 /// replaceAllUsesWith - Replace all uses of debug info referenced by
288 /// this descriptor. After this completes, the current debug info value
290 void replaceAllUsesWith(DIDescriptor &D);
293 /// DICompositeType - This descriptor holds a type that can refer to multiple
294 /// other types, like a function or struct.
295 /// FIXME: Why is this a DIDerivedType??
296 class DICompositeType : public DIDerivedType {
298 explicit DICompositeType(MDNode *N = 0)
299 : DIDerivedType(N, true, true) {
300 if (N && !isCompositeType())
304 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
305 unsigned getRunTimeLang() const { return getUnsignedField(11); }
307 /// Verify - Verify that a composite type descriptor is well formed.
310 /// dump - print composite type.
314 /// DIGlobal - This is a common class for global variables and subprograms.
315 class DIGlobal : public DIDescriptor {
317 explicit DIGlobal(MDNode *N, unsigned RequiredTag)
318 : DIDescriptor(N, RequiredTag) {}
321 virtual ~DIGlobal() {}
323 DIDescriptor getContext() const { return getDescriptorField(2); }
324 StringRef getName() const { return getStringField(3); }
325 StringRef getDisplayName() const { return getStringField(4); }
326 StringRef getLinkageName() const { return getStringField(5); }
327 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
328 unsigned getLineNumber() const { return getUnsignedField(7); }
329 DIType getType() const { return getFieldAs<DIType>(8); }
331 /// isLocalToUnit - Return true if this subprogram is local to the current
332 /// compile unit, like 'static' in C.
333 unsigned isLocalToUnit() const { return getUnsignedField(9); }
334 unsigned isDefinition() const { return getUnsignedField(10); }
336 /// dump - print global.
340 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
341 class DISubprogram : public DIScope {
343 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {
344 if (DbgNode && !isSubprogram())
348 DIDescriptor getContext() const { return getDescriptorField(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{ return getFieldAs<DICompileUnit>(6); }
353 unsigned getLineNumber() const { return getUnsignedField(7); }
354 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
356 /// getReturnTypeName - Subprogram return types are encoded either as
357 /// DIType or as DICompositeType.
358 StringRef getReturnTypeName() const {
359 DICompositeType DCT(getFieldAs<DICompositeType>(8));
361 DIArray A = DCT.getTypeArray();
362 DIType T(A.getElement(0).getNode());
365 DIType T(getFieldAs<DIType>(8));
369 /// isLocalToUnit - Return true if this subprogram is local to the current
370 /// compile unit, like 'static' in C.
371 unsigned isLocalToUnit() const { return getUnsignedField(9); }
372 unsigned isDefinition() const { return getUnsignedField(10); }
374 unsigned getVirtuality() const {
375 if (DbgNode->getNumElements() < 14)
377 return getUnsignedField(11);
380 unsigned getVirtualIndex() const {
381 if (DbgNode->getNumElements() < 14)
383 return getUnsignedField(12);
386 DICompositeType getContainingType() const {
387 assert (DbgNode->getNumElements() >= 14 && "Invalid type!");
388 return getFieldAs<DICompositeType>(13);
391 StringRef getFilename() const { return getCompileUnit().getFilename();}
392 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
394 /// Verify - Verify that a subprogram descriptor is well formed.
397 /// dump - print subprogram.
400 /// describes - Return true if this subprogram provides debugging
401 /// information for the function F.
402 bool describes(const Function *F);
405 /// DIGlobalVariable - This is a wrapper for a global variable.
406 class DIGlobalVariable : public DIGlobal {
408 explicit DIGlobalVariable(MDNode *N = 0)
409 : DIGlobal(N, dwarf::DW_TAG_variable) {}
411 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
413 /// Verify - Verify that a global variable descriptor is well formed.
416 /// dump - print global variable.
420 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
422 class DIVariable : public DIDescriptor {
424 explicit DIVariable(MDNode *N = 0)
426 if (DbgNode && !isVariable())
430 DIDescriptor getContext() const { return getDescriptorField(1); }
431 StringRef getName() const { return getStringField(2); }
432 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
433 unsigned getLineNumber() const { return getUnsignedField(4); }
434 DIType getType() const { return getFieldAs<DIType>(5); }
437 /// Verify - Verify that a variable descriptor is well formed.
440 /// HasComplexAddr - Return true if the variable has a complex address.
441 bool hasComplexAddress() const {
442 return getNumAddrElements() > 0;
445 unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; }
447 uint64_t getAddrElement(unsigned Idx) const {
448 return getUInt64Field(Idx+6);
451 /// isBlockByrefVariable - Return true if the variable was declared as
452 /// a "__block" variable (Apple Blocks).
453 bool isBlockByrefVariable() const {
454 return getType().isBlockByrefStruct();
457 /// dump - print variable.
461 /// DILexicalBlock - This is a wrapper for a lexical block.
462 class DILexicalBlock : public DIScope {
464 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {
465 if (DbgNode && !isLexicalBlock())
468 DIScope getContext() const { return getFieldAs<DIScope>(1); }
469 StringRef getDirectory() const { return getContext().getDirectory(); }
470 StringRef getFilename() const { return getContext().getFilename(); }
473 /// DILocation - This object holds location information. This object
474 /// is not associated with any DWARF tag.
475 class DILocation : public DIDescriptor {
477 explicit DILocation(MDNode *N) : DIDescriptor(N) { ; }
479 unsigned getLineNumber() const { return getUnsignedField(0); }
480 unsigned getColumnNumber() const { return getUnsignedField(1); }
481 DIScope getScope() const { return getFieldAs<DIScope>(2); }
482 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
483 StringRef getFilename() const { return getScope().getFilename(); }
484 StringRef getDirectory() const { return getScope().getDirectory(); }
487 /// DIFactory - This object assists with the construction of the various
491 LLVMContext& VMContext;
493 const Type *EmptyStructPtr; // "{}*".
494 Function *DeclareFn; // llvm.dbg.declare
495 Function *ValueFn; // llvm.dbg.value
497 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
498 void operator=(const DIFactory&); // DO NOT IMPLEMENT
500 enum ComplexAddrKind { OpPlus=1, OpDeref };
502 explicit DIFactory(Module &m);
504 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
505 /// This implicitly uniques the arrays created.
506 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
508 /// GetOrCreateSubrange - Create a descriptor for a value range. This
509 /// implicitly uniques the values returned.
510 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
512 /// CreateCompileUnit - Create a new descriptor for the specified compile
514 DICompileUnit CreateCompileUnit(unsigned LangID,
519 bool isOptimized = false,
520 StringRef Flags = "",
521 unsigned RunTimeVer = 0);
523 /// CreateEnumerator - Create a single enumerator value.
524 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
526 /// CreateBasicType - Create a basic type like int, float, etc.
527 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
528 DICompileUnit CompileUnit, unsigned LineNumber,
529 uint64_t SizeInBits, uint64_t AlignInBits,
530 uint64_t OffsetInBits, unsigned Flags,
533 /// CreateBasicType - Create a basic type like int, float, etc.
534 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
535 DICompileUnit CompileUnit, unsigned LineNumber,
536 Constant *SizeInBits, Constant *AlignInBits,
537 Constant *OffsetInBits, unsigned Flags,
540 /// CreateDerivedType - Create a derived type like const qualified type,
541 /// pointer, typedef, etc.
542 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
544 DICompileUnit CompileUnit,
546 uint64_t SizeInBits, uint64_t AlignInBits,
547 uint64_t OffsetInBits, unsigned Flags,
550 /// CreateDerivedType - Create a derived type like const qualified type,
551 /// pointer, typedef, etc.
552 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
554 DICompileUnit CompileUnit,
556 Constant *SizeInBits, Constant *AlignInBits,
557 Constant *OffsetInBits, unsigned Flags,
560 /// CreateCompositeType - Create a composite type like array, struct, etc.
561 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
563 DICompileUnit CompileUnit,
566 uint64_t AlignInBits,
567 uint64_t OffsetInBits, unsigned Flags,
570 unsigned RunTimeLang = 0);
572 /// CreateCompositeType - Create a composite type like array, struct, etc.
573 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
575 DICompileUnit CompileUnit,
577 Constant *SizeInBits,
578 Constant *AlignInBits,
579 Constant *OffsetInBits, unsigned Flags,
582 unsigned RunTimeLang = 0);
584 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
585 /// See comments in DISubprogram for descriptions of these fields.
586 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
587 StringRef DisplayName,
588 StringRef LinkageName,
589 DICompileUnit CompileUnit, unsigned LineNo,
590 DIType Type, bool isLocalToUnit,
596 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
597 /// given declaration.
598 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
600 /// CreateGlobalVariable - Create a new descriptor for the specified global.
602 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
603 StringRef DisplayName,
604 StringRef LinkageName,
605 DICompileUnit CompileUnit,
606 unsigned LineNo, DIType Type, bool isLocalToUnit,
607 bool isDefinition, llvm::GlobalVariable *GV);
609 /// CreateVariable - Create a new descriptor for the specified variable.
610 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
612 DICompileUnit CompileUnit, unsigned LineNo,
615 /// CreateComplexVariable - Create a new descriptor for the specified
616 /// variable which has a complex address expression for its address.
617 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
618 const std::string &Name,
619 DICompileUnit CompileUnit, unsigned LineNo,
621 SmallVector<Value *, 9> &addr);
623 /// CreateLexicalBlock - This creates a descriptor for a lexical block
624 /// with the specified parent context.
625 DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
627 /// CreateLocation - Creates a debug info location.
628 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
629 DIScope S, DILocation OrigLoc);
631 /// CreateLocation - Creates a debug info location.
632 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
633 DIScope S, MDNode *OrigLoc = 0);
635 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
636 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
637 BasicBlock *InsertAtEnd);
639 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
640 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
641 Instruction *InsertBefore);
643 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
644 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
645 DIVariable D, BasicBlock *InsertAtEnd);
647 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
648 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
649 DIVariable D, Instruction *InsertBefore);
651 Constant *GetTagConstant(unsigned TAG);
654 /// Finds the stoppoint coressponding to this instruction, that is the
655 /// stoppoint that dominates this instruction
656 const DbgStopPointInst *findStopPoint(const Instruction *Inst);
658 /// Finds the stoppoint corresponding to first real (non-debug intrinsic)
659 /// instruction in this Basic Block, and returns the stoppoint for it.
660 const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB);
662 /// Finds the dbg.declare intrinsic corresponding to this value if any.
663 /// It looks through pointer casts too.
664 const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true);
666 /// Find the debug info descriptor corresponding to this global variable.
667 Value *findDbgGlobalDeclare(GlobalVariable *V);
669 bool getLocationInfo(const Value *V, std::string &DisplayName,
670 std::string &Type, unsigned &LineNo, std::string &File,
673 /// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
675 bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI,
676 CodeGenOpt::Level OptLev);
678 /// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
680 bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI,
681 CodeGenOpt::Level OptLev);
683 /// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
685 bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI,
686 CodeGenOpt::Level OptLev);
688 /// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
690 bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI,
691 CodeGenOpt::Level OptLev);
693 /// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
695 bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI,
696 CodeGenOpt::Level OptLev);
698 /// ExtractDebugLocation - Extract debug location information
699 /// from llvm.dbg.stoppoint intrinsic.
700 DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
701 DebugLocTracker &DebugLocInfo);
703 /// ExtractDebugLocation - Extract debug location information
705 DebugLoc ExtractDebugLocation(DILocation &Loc,
706 DebugLocTracker &DebugLocInfo);
708 /// ExtractDebugLocation - Extract debug location information
709 /// from llvm.dbg.func_start intrinsic.
710 DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
711 DebugLocTracker &DebugLocInfo);
713 /// getDISubprogram - Find subprogram that is enclosing this scope.
714 DISubprogram getDISubprogram(MDNode *Scope);
716 /// getDICompositeType - Find underlying composite type.
717 DICompositeType getDICompositeType(DIType T);
719 class DebugInfoFinder {
722 /// processModule - Process entire module and collect debug info
724 void processModule(Module &M);
727 /// processType - Process DIType.
728 void processType(DIType DT);
730 /// processLexicalBlock - Process DILexicalBlock.
731 void processLexicalBlock(DILexicalBlock LB);
733 /// processSubprogram - Process DISubprogram.
734 void processSubprogram(DISubprogram SP);
736 /// processDeclare - Process DbgDeclareInst.
737 void processDeclare(DbgDeclareInst *DDI);
739 /// processLocation - Process DILocation.
740 void processLocation(DILocation Loc);
742 /// addCompileUnit - Add compile unit into CUs.
743 bool addCompileUnit(DICompileUnit CU);
745 /// addGlobalVariable - Add global variable into GVs.
746 bool addGlobalVariable(DIGlobalVariable DIG);
748 // addSubprogram - Add subprgoram into SPs.
749 bool addSubprogram(DISubprogram SP);
751 /// addType - Add type into Tys.
752 bool addType(DIType DT);
755 typedef SmallVector<MDNode *, 8>::iterator iterator;
756 iterator compile_unit_begin() { return CUs.begin(); }
757 iterator compile_unit_end() { return CUs.end(); }
758 iterator subprogram_begin() { return SPs.begin(); }
759 iterator subprogram_end() { return SPs.end(); }
760 iterator global_variable_begin() { return GVs.begin(); }
761 iterator global_variable_end() { return GVs.end(); }
762 iterator type_begin() { return TYs.begin(); }
763 iterator type_end() { return TYs.end(); }
765 unsigned compile_unit_count() { return CUs.size(); }
766 unsigned global_variable_count() { return GVs.size(); }
767 unsigned subprogram_count() { return SPs.size(); }
768 unsigned type_count() { return TYs.size(); }
771 SmallVector<MDNode *, 8> CUs; // Compile Units
772 SmallVector<MDNode *, 8> SPs; // Subprograms
773 SmallVector<MDNode *, 8> GVs; // Global Variables;
774 SmallVector<MDNode *, 8> TYs; // Types
775 SmallPtrSet<MDNode *, 64> NodesSeen;
777 } // end namespace llvm