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 isNameSpace() const;
103 bool isLexicalBlock() const;
104 bool isSubrange() const;
105 bool isEnumerator() const;
107 bool isGlobal() const;
110 /// DISubrange - This is used to represent ranges, for array bounds.
111 class DISubrange : public DIDescriptor {
113 explicit DISubrange(MDNode *N = 0)
114 : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
116 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
117 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
120 /// DIArray - This descriptor holds an array of descriptors.
121 class DIArray : public DIDescriptor {
123 explicit DIArray(MDNode *N = 0)
126 unsigned getNumElements() const;
127 DIDescriptor getElement(unsigned Idx) const {
128 return getDescriptorField(Idx);
132 /// DIScope - A base class for various scopes.
133 class DIScope : public DIDescriptor {
135 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
136 if (DbgNode && !isScope())
139 virtual ~DIScope() {}
141 StringRef getFilename() const;
142 StringRef getDirectory() const;
145 /// DICompileUnit - A wrapper for a compile unit.
146 class DICompileUnit : public DIScope {
148 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {
149 if (DbgNode && !isCompileUnit())
153 unsigned getLanguage() const { return getUnsignedField(2); }
154 StringRef getFilename() const { return getStringField(3); }
155 StringRef getDirectory() const { return getStringField(4); }
156 StringRef getProducer() const { return getStringField(5); }
158 /// isMain - Each input file is encoded as a separate compile unit in LLVM
159 /// debugging information output. However, many target specific tool chains
160 /// prefer to encode only one compile unit in an object file. In this
161 /// situation, the LLVM code generator will include debugging information
162 /// entities in the compile unit that is marked as main compile unit. The
163 /// code generator accepts maximum one main compile unit per module. If a
164 /// module does not contain any main compile unit then the code generator
165 /// will emit multiple compile units in the output object file.
167 bool isMain() const { return getUnsignedField(6); }
168 bool isOptimized() const { return getUnsignedField(7); }
169 StringRef getFlags() const { return getStringField(8); }
170 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
172 /// Verify - Verify that a compile unit is well formed.
175 /// dump - print compile unit.
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)
185 : DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
187 StringRef getName() const { return getStringField(1); }
188 uint64_t getEnumValue() const { return getUInt64Field(2); }
191 /// DIType - This is a wrapper for a type.
192 /// FIXME: Types should be factored much better so that CV qualifiers and
193 /// others do not require a huge and empty descriptor full of zeros.
194 class DIType : public DIDescriptor {
197 FlagPrivate = 1 << 0,
198 FlagProtected = 1 << 1,
199 FlagFwdDecl = 1 << 2,
200 FlagAppleBlock = 1 << 3,
201 FlagBlockByrefStruct = 1 << 4,
206 DIType(MDNode *N, unsigned Tag)
207 : DIDescriptor(N, Tag) {}
208 // This ctor is used when the Tag has already been validated by a derived
210 DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
214 /// Verify - Verify that a type descriptor is well formed.
217 explicit DIType(MDNode *N);
221 DIDescriptor getContext() const { return getDescriptorField(1); }
222 StringRef getName() const { return getStringField(2); }
223 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
224 unsigned getLineNumber() const { return getUnsignedField(4); }
225 uint64_t getSizeInBits() const { return getUInt64Field(5); }
226 uint64_t getAlignInBits() const { return getUInt64Field(6); }
227 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
228 // carry this is just plain insane.
229 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
230 unsigned getFlags() const { return getUnsignedField(8); }
231 bool isPrivate() const {
232 return (getFlags() & FlagPrivate) != 0;
234 bool isProtected() const {
235 return (getFlags() & FlagProtected) != 0;
237 bool isForwardDecl() const {
238 return (getFlags() & FlagFwdDecl) != 0;
240 // isAppleBlock - Return true if this is the Apple Blocks extension.
241 bool isAppleBlockExtension() const {
242 return (getFlags() & FlagAppleBlock) != 0;
244 bool isBlockByrefStruct() const {
245 return (getFlags() & FlagBlockByrefStruct) != 0;
247 bool isVirtual() const {
248 return (getFlags() & FlagVirtual) != 0;
251 /// dump - print type.
255 /// DIBasicType - A basic type, like 'int' or 'float'.
256 class DIBasicType : public DIType {
258 explicit DIBasicType(MDNode *N = 0)
259 : DIType(N, dwarf::DW_TAG_base_type) {}
261 unsigned getEncoding() const { return getUnsignedField(9); }
263 /// dump - print basic type.
267 /// DIDerivedType - A simple derived type, like a const qualified type,
268 /// a typedef, a pointer or reference, etc.
269 class DIDerivedType : public DIType {
271 explicit DIDerivedType(MDNode *N, bool, bool)
272 : DIType(N, true, true) {}
274 explicit DIDerivedType(MDNode *N = 0)
275 : DIType(N, true, true) {
276 if (DbgNode && !isDerivedType())
280 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
282 /// getOriginalTypeSize - If this type is derived from a base type then
283 /// return base type size.
284 uint64_t getOriginalTypeSize() const;
285 /// dump - print derived type.
288 /// replaceAllUsesWith - Replace all uses of debug info referenced by
289 /// this descriptor. After this completes, the current debug info value
291 void replaceAllUsesWith(DIDescriptor &D);
294 /// DICompositeType - This descriptor holds a type that can refer to multiple
295 /// other types, like a function or struct.
296 /// FIXME: Why is this a DIDerivedType??
297 class DICompositeType : public DIDerivedType {
299 explicit DICompositeType(MDNode *N = 0)
300 : DIDerivedType(N, true, true) {
301 if (N && !isCompositeType())
305 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
306 unsigned getRunTimeLang() const { return getUnsignedField(11); }
308 /// Verify - Verify that a composite type descriptor is well formed.
311 /// dump - print composite type.
315 /// DIGlobal - This is a common class for global variables and subprograms.
316 class DIGlobal : public DIDescriptor {
318 explicit DIGlobal(MDNode *N, unsigned RequiredTag)
319 : DIDescriptor(N, RequiredTag) {}
322 virtual ~DIGlobal() {}
324 DIDescriptor getContext() const { return getDescriptorField(2); }
325 StringRef getName() const { return getStringField(3); }
326 StringRef getDisplayName() const { return getStringField(4); }
327 StringRef getLinkageName() const { return getStringField(5); }
328 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
329 unsigned getLineNumber() const { return getUnsignedField(7); }
330 DIType getType() const { return getFieldAs<DIType>(8); }
332 /// isLocalToUnit - Return true if this subprogram is local to the current
333 /// compile unit, like 'static' in C.
334 unsigned isLocalToUnit() const { return getUnsignedField(9); }
335 unsigned isDefinition() const { return getUnsignedField(10); }
337 /// dump - print global.
341 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
342 class DISubprogram : public DIScope {
344 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {
345 if (DbgNode && !isSubprogram())
349 DIDescriptor getContext() const { return getDescriptorField(2); }
350 StringRef getName() const { return getStringField(3); }
351 StringRef getDisplayName() const { return getStringField(4); }
352 StringRef getLinkageName() const { return getStringField(5); }
353 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
354 unsigned getLineNumber() const { return getUnsignedField(7); }
355 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
357 /// getReturnTypeName - Subprogram return types are encoded either as
358 /// DIType or as DICompositeType.
359 StringRef getReturnTypeName() const {
360 DICompositeType DCT(getFieldAs<DICompositeType>(8));
362 DIArray A = DCT.getTypeArray();
363 DIType T(A.getElement(0).getNode());
366 DIType T(getFieldAs<DIType>(8));
370 /// isLocalToUnit - Return true if this subprogram is local to the current
371 /// compile unit, like 'static' in C.
372 unsigned isLocalToUnit() const { return getUnsignedField(9); }
373 unsigned isDefinition() const { return getUnsignedField(10); }
375 unsigned getVirtuality() const {
376 if (DbgNode->getNumElements() < 14)
378 return getUnsignedField(11);
381 unsigned getVirtualIndex() const {
382 if (DbgNode->getNumElements() < 14)
384 return getUnsignedField(12);
387 DICompositeType getContainingType() const {
388 assert (DbgNode->getNumElements() >= 14 && "Invalid type!");
389 return getFieldAs<DICompositeType>(13);
392 StringRef getFilename() const { return getCompileUnit().getFilename();}
393 StringRef getDirectory() const { return getCompileUnit().getDirectory();}
395 /// Verify - Verify that a subprogram descriptor is well formed.
398 /// dump - print subprogram.
401 /// describes - Return true if this subprogram provides debugging
402 /// information for the function F.
403 bool describes(const Function *F);
406 /// DIGlobalVariable - This is a wrapper for a global variable.
407 class DIGlobalVariable : public DIGlobal {
409 explicit DIGlobalVariable(MDNode *N = 0)
410 : DIGlobal(N, dwarf::DW_TAG_variable) {}
412 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
414 /// Verify - Verify that a global variable descriptor is well formed.
417 /// dump - print global variable.
421 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
423 class DIVariable : public DIDescriptor {
425 explicit DIVariable(MDNode *N = 0)
427 if (DbgNode && !isVariable())
431 DIDescriptor getContext() const { return getDescriptorField(1); }
432 StringRef getName() const { return getStringField(2); }
433 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
434 unsigned getLineNumber() const { return getUnsignedField(4); }
435 DIType getType() const { return getFieldAs<DIType>(5); }
438 /// Verify - Verify that a variable descriptor is well formed.
441 /// HasComplexAddr - Return true if the variable has a complex address.
442 bool hasComplexAddress() const {
443 return getNumAddrElements() > 0;
446 unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; }
448 uint64_t getAddrElement(unsigned Idx) const {
449 return getUInt64Field(Idx+6);
452 /// isBlockByrefVariable - Return true if the variable was declared as
453 /// a "__block" variable (Apple Blocks).
454 bool isBlockByrefVariable() const {
455 return getType().isBlockByrefStruct();
458 /// dump - print variable.
462 /// DILexicalBlock - This is a wrapper for a lexical block.
463 class DILexicalBlock : public DIScope {
465 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {
466 if (DbgNode && !isLexicalBlock())
469 DIScope getContext() const { return getFieldAs<DIScope>(1); }
470 StringRef getDirectory() const { return getContext().getDirectory(); }
471 StringRef getFilename() const { return getContext().getFilename(); }
474 /// DINameSpace - A wrapper for a C++ style name space.
475 class DINameSpace : public DIScope {
477 explicit DINameSpace(MDNode *N = 0) : DIScope(N) {
478 if (DbgNode && !isNameSpace())
482 DIScope getContext() const { return getFieldAs<DIScope>(1); }
483 StringRef getName() const { return getStringField(2); }
484 StringRef getDirectory() const { return getContext().getDirectory(); }
485 StringRef getFilename() const { return getContext().getFilename(); }
486 DICompileUnit getCompileUnit() const { return getFieldAs<DICompileUnit>(3); }
487 unsigned getLineNumber() const { return getUnsignedField(4); }
490 /// DILocation - This object holds location information. This object
491 /// is not associated with any DWARF tag.
492 class DILocation : public DIDescriptor {
494 explicit DILocation(MDNode *N) : DIDescriptor(N) { ; }
496 unsigned getLineNumber() const { return getUnsignedField(0); }
497 unsigned getColumnNumber() const { return getUnsignedField(1); }
498 DIScope getScope() const { return getFieldAs<DIScope>(2); }
499 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
500 StringRef getFilename() const { return getScope().getFilename(); }
501 StringRef getDirectory() const { return getScope().getDirectory(); }
504 /// DIFactory - This object assists with the construction of the various
508 LLVMContext& VMContext;
510 const Type *EmptyStructPtr; // "{}*".
511 Function *DeclareFn; // llvm.dbg.declare
512 Function *ValueFn; // llvm.dbg.value
514 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
515 void operator=(const DIFactory&); // DO NOT IMPLEMENT
517 enum ComplexAddrKind { OpPlus=1, OpDeref };
519 explicit DIFactory(Module &m);
521 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
522 /// This implicitly uniques the arrays created.
523 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
525 /// GetOrCreateSubrange - Create a descriptor for a value range. This
526 /// implicitly uniques the values returned.
527 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
529 /// CreateCompileUnit - Create a new descriptor for the specified compile
531 DICompileUnit CreateCompileUnit(unsigned LangID,
536 bool isOptimized = false,
537 StringRef Flags = "",
538 unsigned RunTimeVer = 0);
540 /// CreateEnumerator - Create a single enumerator value.
541 DIEnumerator CreateEnumerator(StringRef Name, uint64_t Val);
543 /// CreateBasicType - Create a basic type like int, float, etc.
544 DIBasicType CreateBasicType(DIDescriptor Context, StringRef Name,
545 DICompileUnit CompileUnit, unsigned LineNumber,
546 uint64_t SizeInBits, uint64_t AlignInBits,
547 uint64_t OffsetInBits, unsigned Flags,
550 /// CreateBasicType - Create a basic type like int, float, etc.
551 DIBasicType CreateBasicTypeEx(DIDescriptor Context, StringRef Name,
552 DICompileUnit CompileUnit, unsigned LineNumber,
553 Constant *SizeInBits, Constant *AlignInBits,
554 Constant *OffsetInBits, unsigned Flags,
557 /// CreateDerivedType - Create a derived type like const qualified type,
558 /// pointer, typedef, etc.
559 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
561 DICompileUnit CompileUnit,
563 uint64_t SizeInBits, uint64_t AlignInBits,
564 uint64_t OffsetInBits, unsigned Flags,
567 /// CreateDerivedType - Create a derived type like const qualified type,
568 /// pointer, typedef, etc.
569 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
571 DICompileUnit CompileUnit,
573 Constant *SizeInBits, Constant *AlignInBits,
574 Constant *OffsetInBits, unsigned Flags,
577 /// CreateCompositeType - Create a composite type like array, struct, etc.
578 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
580 DICompileUnit CompileUnit,
583 uint64_t AlignInBits,
584 uint64_t OffsetInBits, unsigned Flags,
587 unsigned RunTimeLang = 0);
589 /// CreateCompositeType - Create a composite type like array, struct, etc.
590 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
592 DICompileUnit CompileUnit,
594 Constant *SizeInBits,
595 Constant *AlignInBits,
596 Constant *OffsetInBits, unsigned Flags,
599 unsigned RunTimeLang = 0);
601 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
602 /// See comments in DISubprogram for descriptions of these fields.
603 DISubprogram CreateSubprogram(DIDescriptor Context, StringRef Name,
604 StringRef DisplayName,
605 StringRef LinkageName,
606 DICompileUnit CompileUnit, unsigned LineNo,
607 DIType Type, bool isLocalToUnit,
613 /// CreateSubprogramDefinition - Create new subprogram descriptor for the
614 /// given declaration.
615 DISubprogram CreateSubprogramDefinition(DISubprogram &SPDeclaration);
617 /// CreateGlobalVariable - Create a new descriptor for the specified global.
619 CreateGlobalVariable(DIDescriptor Context, StringRef Name,
620 StringRef DisplayName,
621 StringRef LinkageName,
622 DICompileUnit CompileUnit,
623 unsigned LineNo, DIType Type, bool isLocalToUnit,
624 bool isDefinition, llvm::GlobalVariable *GV);
626 /// CreateVariable - Create a new descriptor for the specified variable.
627 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
629 DICompileUnit CompileUnit, unsigned LineNo,
632 /// CreateComplexVariable - Create a new descriptor for the specified
633 /// variable which has a complex address expression for its address.
634 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
635 const std::string &Name,
636 DICompileUnit CompileUnit, unsigned LineNo,
638 SmallVector<Value *, 9> &addr);
640 /// CreateLexicalBlock - This creates a descriptor for a lexical block
641 /// with the specified parent context.
642 DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
644 /// CreateNameSpace - This creates new descriptor for a namespace
645 /// with the specified parent context.
646 DINameSpace CreateNameSpace(DIDescriptor Context, StringRef Name,
647 DICompileUnit CU, unsigned LineNo);
649 /// CreateLocation - Creates a debug info location.
650 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
651 DIScope S, DILocation OrigLoc);
653 /// CreateLocation - Creates a debug info location.
654 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
655 DIScope S, MDNode *OrigLoc = 0);
657 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
658 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
659 BasicBlock *InsertAtEnd);
661 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
662 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
663 Instruction *InsertBefore);
665 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
666 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
667 DIVariable D, BasicBlock *InsertAtEnd);
669 /// InsertDbgValueIntrinsic - Insert a new llvm.dbg.value intrinsic call.
670 Instruction *InsertDbgValueIntrinsic(llvm::Value *V, llvm::Value *Offset,
671 DIVariable D, Instruction *InsertBefore);
673 Constant *GetTagConstant(unsigned TAG);
676 /// Finds the stoppoint coressponding to this instruction, that is the
677 /// stoppoint that dominates this instruction
678 const DbgStopPointInst *findStopPoint(const Instruction *Inst);
680 /// Finds the stoppoint corresponding to first real (non-debug intrinsic)
681 /// instruction in this Basic Block, and returns the stoppoint for it.
682 const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB);
684 /// Finds the dbg.declare intrinsic corresponding to this value if any.
685 /// It looks through pointer casts too.
686 const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true);
688 /// Find the debug info descriptor corresponding to this global variable.
689 Value *findDbgGlobalDeclare(GlobalVariable *V);
691 bool getLocationInfo(const Value *V, std::string &DisplayName,
692 std::string &Type, unsigned &LineNo, std::string &File,
695 /// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
697 bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI,
698 CodeGenOpt::Level OptLev);
700 /// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
702 bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI,
703 CodeGenOpt::Level OptLev);
705 /// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
707 bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI,
708 CodeGenOpt::Level OptLev);
710 /// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
712 bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI,
713 CodeGenOpt::Level OptLev);
715 /// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
717 bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI,
718 CodeGenOpt::Level OptLev);
720 /// ExtractDebugLocation - Extract debug location information
721 /// from llvm.dbg.stoppoint intrinsic.
722 DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
723 DebugLocTracker &DebugLocInfo);
725 /// ExtractDebugLocation - Extract debug location information
727 DebugLoc ExtractDebugLocation(DILocation &Loc,
728 DebugLocTracker &DebugLocInfo);
730 /// ExtractDebugLocation - Extract debug location information
731 /// from llvm.dbg.func_start intrinsic.
732 DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
733 DebugLocTracker &DebugLocInfo);
735 /// getDISubprogram - Find subprogram that is enclosing this scope.
736 DISubprogram getDISubprogram(MDNode *Scope);
738 /// getDICompositeType - Find underlying composite type.
739 DICompositeType getDICompositeType(DIType T);
741 class DebugInfoFinder {
744 /// processModule - Process entire module and collect debug info
746 void processModule(Module &M);
749 /// processType - Process DIType.
750 void processType(DIType DT);
752 /// processLexicalBlock - Process DILexicalBlock.
753 void processLexicalBlock(DILexicalBlock LB);
755 /// processSubprogram - Process DISubprogram.
756 void processSubprogram(DISubprogram SP);
758 /// processDeclare - Process DbgDeclareInst.
759 void processDeclare(DbgDeclareInst *DDI);
761 /// processLocation - Process DILocation.
762 void processLocation(DILocation Loc);
764 /// addCompileUnit - Add compile unit into CUs.
765 bool addCompileUnit(DICompileUnit CU);
767 /// addGlobalVariable - Add global variable into GVs.
768 bool addGlobalVariable(DIGlobalVariable DIG);
770 // addSubprogram - Add subprgoram into SPs.
771 bool addSubprogram(DISubprogram SP);
773 /// addType - Add type into Tys.
774 bool addType(DIType DT);
777 typedef SmallVector<MDNode *, 8>::iterator iterator;
778 iterator compile_unit_begin() { return CUs.begin(); }
779 iterator compile_unit_end() { return CUs.end(); }
780 iterator subprogram_begin() { return SPs.begin(); }
781 iterator subprogram_end() { return SPs.end(); }
782 iterator global_variable_begin() { return GVs.begin(); }
783 iterator global_variable_end() { return GVs.end(); }
784 iterator type_begin() { return TYs.begin(); }
785 iterator type_end() { return TYs.end(); }
787 unsigned compile_unit_count() { return CUs.size(); }
788 unsigned global_variable_count() { return GVs.size(); }
789 unsigned subprogram_count() { return SPs.size(); }
790 unsigned type_count() { return TYs.size(); }
793 SmallVector<MDNode *, 8> CUs; // Compile Units
794 SmallVector<MDNode *, 8> SPs; // Subprograms
795 SmallVector<MDNode *, 8> GVs; // Global Variables;
796 SmallVector<MDNode *, 8> TYs; // Types
797 SmallPtrSet<MDNode *, 64> NodesSeen;
799 } // end namespace llvm