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;
49 TrackingVH<MDNode> DbgNode;
51 /// DIDescriptor constructor. If the specified node is non-null, check
52 /// to make sure that the tag in the descriptor matches 'RequiredTag'. If
53 /// not, the debug info is corrupt and we ignore it.
54 DIDescriptor(MDNode *N, unsigned RequiredTag);
56 const char *getStringField(unsigned Elt) const;
57 unsigned getUnsignedField(unsigned Elt) const {
58 return (unsigned)getUInt64Field(Elt);
60 uint64_t getUInt64Field(unsigned Elt) const;
61 DIDescriptor getDescriptorField(unsigned Elt) const;
63 template <typename DescTy>
64 DescTy getFieldAs(unsigned Elt) const {
65 return DescTy(getDescriptorField(Elt).getNode());
68 GlobalVariable *getGlobalVariableField(unsigned Elt) const;
71 explicit DIDescriptor() : DbgNode(0) {}
72 explicit DIDescriptor(MDNode *N) : DbgNode(N) {}
74 bool isNull() const { return DbgNode == 0; }
76 MDNode *getNode() const { return DbgNode; }
78 unsigned getVersion() const {
79 return getUnsignedField(0) & LLVMDebugVersionMask;
82 unsigned getTag() const {
83 return getUnsignedField(0) & ~LLVMDebugVersionMask;
86 /// ValidDebugInfo - Return true if N represents valid debug info value.
87 static bool ValidDebugInfo(MDNode *N, CodeGenOpt::Level OptLevel);
89 /// dump - print descriptor.
92 bool isDerivedType() const;
93 bool isCompositeType() const;
94 bool isBasicType() const;
95 bool isVariable() const;
96 bool isSubprogram() const;
97 bool isGlobalVariable() const;
99 bool isCompileUnit() const;
100 bool isLexicalBlock() const;
101 bool isSubrange() const;
102 bool isEnumerator() const;
104 bool isGlobal() const;
107 /// DISubrange - This is used to represent ranges, for array bounds.
108 class DISubrange : public DIDescriptor {
110 explicit DISubrange(MDNode *N = 0)
111 : DIDescriptor(N, dwarf::DW_TAG_subrange_type) {}
113 int64_t getLo() const { return (int64_t)getUInt64Field(1); }
114 int64_t getHi() const { return (int64_t)getUInt64Field(2); }
117 /// DIArray - This descriptor holds an array of descriptors.
118 class DIArray : public DIDescriptor {
120 explicit DIArray(MDNode *N = 0)
123 unsigned getNumElements() const;
124 DIDescriptor getElement(unsigned Idx) const {
125 return getDescriptorField(Idx);
129 /// DIScope - A base class for various scopes.
130 class DIScope : public DIDescriptor {
132 explicit DIScope(MDNode *N = 0) : DIDescriptor (N) {
133 if (DbgNode && !isScope())
136 virtual ~DIScope() {}
138 const char *getFilename() const;
139 const char *getDirectory() const;
142 /// DICompileUnit - A wrapper for a compile unit.
143 class DICompileUnit : public DIScope {
145 explicit DICompileUnit(MDNode *N = 0) : DIScope(N) {
146 if (DbgNode && !isCompileUnit())
150 unsigned getLanguage() const { return getUnsignedField(2); }
151 const char *getFilename() const { return getStringField(3); }
152 const char *getDirectory() const { return getStringField(4); }
153 const char *getProducer() const { return getStringField(5); }
155 /// isMain - Each input file is encoded as a separate compile unit in LLVM
156 /// debugging information output. However, many target specific tool chains
157 /// prefer to encode only one compile unit in an object file. In this
158 /// situation, the LLVM code generator will include debugging information
159 /// entities in the compile unit that is marked as main compile unit. The
160 /// code generator accepts maximum one main compile unit per module. If a
161 /// module does not contain any main compile unit then the code generator
162 /// will emit multiple compile units in the output object file.
164 bool isMain() const { return getUnsignedField(6); }
165 bool isOptimized() const { return getUnsignedField(7); }
166 const char *getFlags() const { return getStringField(8); }
167 unsigned getRunTimeVersion() const { return getUnsignedField(9); }
169 /// Verify - Verify that a compile unit is well formed.
172 /// dump - print compile unit.
176 /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}').
177 /// FIXME: it seems strange that this doesn't have either a reference to the
178 /// type/precision or a file/line pair for location info.
179 class DIEnumerator : public DIDescriptor {
181 explicit DIEnumerator(MDNode *N = 0)
182 : DIDescriptor(N, dwarf::DW_TAG_enumerator) {}
184 const char *getName() const { return getStringField(1); }
185 uint64_t getEnumValue() const { return getUInt64Field(2); }
188 /// DIType - This is a wrapper for a type.
189 /// FIXME: Types should be factored much better so that CV qualifiers and
190 /// others do not require a huge and empty descriptor full of zeros.
191 class DIType : public DIDescriptor {
194 FlagPrivate = 1 << 0,
195 FlagProtected = 1 << 1,
196 FlagFwdDecl = 1 << 2,
197 FlagAppleBlock = 1 << 3,
198 FlagBlockByrefStruct = 1 << 4
202 DIType(MDNode *N, unsigned Tag)
203 : DIDescriptor(N, Tag) {}
204 // This ctor is used when the Tag has already been validated by a derived
206 DIType(MDNode *N, bool, bool) : DIDescriptor(N) {}
210 /// Verify - Verify that a type descriptor is well formed.
213 explicit DIType(MDNode *N);
217 DIDescriptor getContext() const { return getDescriptorField(1); }
218 const char *getName() const { return getStringField(2); }
219 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
220 unsigned getLineNumber() const { return getUnsignedField(4); }
221 uint64_t getSizeInBits() const { return getUInt64Field(5); }
222 uint64_t getAlignInBits() const { return getUInt64Field(6); }
223 // FIXME: Offset is only used for DW_TAG_member nodes. Making every type
224 // carry this is just plain insane.
225 uint64_t getOffsetInBits() const { return getUInt64Field(7); }
226 unsigned getFlags() const { return getUnsignedField(8); }
227 bool isPrivate() const {
228 return (getFlags() & FlagPrivate) != 0;
230 bool isProtected() const {
231 return (getFlags() & FlagProtected) != 0;
233 bool isForwardDecl() const {
234 return (getFlags() & FlagFwdDecl) != 0;
236 // isAppleBlock - Return true if this is the Apple Blocks extension.
237 bool isAppleBlockExtension() const {
238 return (getFlags() & FlagAppleBlock) != 0;
240 bool isBlockByrefStruct() const {
241 return (getFlags() & FlagBlockByrefStruct) != 0;
244 /// dump - print type.
248 /// DIBasicType - A basic type, like 'int' or 'float'.
249 class DIBasicType : public DIType {
251 explicit DIBasicType(MDNode *N = 0)
252 : DIType(N, dwarf::DW_TAG_base_type) {}
254 unsigned getEncoding() const { return getUnsignedField(9); }
256 /// dump - print basic type.
260 /// DIDerivedType - A simple derived type, like a const qualified type,
261 /// a typedef, a pointer or reference, etc.
262 class DIDerivedType : public DIType {
264 explicit DIDerivedType(MDNode *N, bool, bool)
265 : DIType(N, true, true) {}
267 explicit DIDerivedType(MDNode *N = 0)
268 : DIType(N, true, true) {
269 if (DbgNode && !isDerivedType())
273 DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); }
275 /// getOriginalTypeSize - If this type is derived from a base type then
276 /// return base type size.
277 uint64_t getOriginalTypeSize() const;
278 /// dump - print derived type.
281 /// replaceAllUsesWith - Replace all uses of debug info referenced by
282 /// this descriptor. After this completes, the current debug info value
284 void replaceAllUsesWith(DIDescriptor &D);
287 /// DICompositeType - This descriptor holds a type that can refer to multiple
288 /// other types, like a function or struct.
289 /// FIXME: Why is this a DIDerivedType??
290 class DICompositeType : public DIDerivedType {
292 explicit DICompositeType(MDNode *N = 0)
293 : DIDerivedType(N, true, true) {
294 if (N && !isCompositeType())
298 DIArray getTypeArray() const { return getFieldAs<DIArray>(10); }
299 unsigned getRunTimeLang() const { return getUnsignedField(11); }
301 /// Verify - Verify that a composite type descriptor is well formed.
304 /// dump - print composite type.
308 /// DIGlobal - This is a common class for global variables and subprograms.
309 class DIGlobal : public DIDescriptor {
311 explicit DIGlobal(MDNode *N, unsigned RequiredTag)
312 : DIDescriptor(N, RequiredTag) {}
315 virtual ~DIGlobal() {}
317 DIDescriptor getContext() const { return getDescriptorField(2); }
318 const char *getName() const { return getStringField(3); }
319 const char *getDisplayName() const { return getStringField(4); }
320 const char *getLinkageName() const { return getStringField(5); }
321 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
322 unsigned getLineNumber() const { return getUnsignedField(7); }
323 DIType getType() const { return getFieldAs<DIType>(8); }
325 /// isLocalToUnit - Return true if this subprogram is local to the current
326 /// compile unit, like 'static' in C.
327 unsigned isLocalToUnit() const { return getUnsignedField(9); }
328 unsigned isDefinition() const { return getUnsignedField(10); }
330 /// dump - print global.
334 /// DISubprogram - This is a wrapper for a subprogram (e.g. a function).
335 class DISubprogram : public DIScope {
337 explicit DISubprogram(MDNode *N = 0) : DIScope(N) {
338 if (DbgNode && !isSubprogram())
342 DIDescriptor getContext() const { return getDescriptorField(2); }
343 const char *getName() const { return getStringField(3); }
344 const char *getDisplayName() const { return getStringField(4); }
345 const char *getLinkageName() const { return getStringField(5); }
346 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); }
347 unsigned getLineNumber() const { return getUnsignedField(7); }
348 DICompositeType getType() const { return getFieldAs<DICompositeType>(8); }
350 /// getReturnTypeName - Subprogram return types are encoded either as
351 /// DIType or as DICompositeType.
352 const char *getReturnTypeName() const {
353 DICompositeType DCT(getFieldAs<DICompositeType>(8));
355 DIArray A = DCT.getTypeArray();
356 DIType T(A.getElement(0).getNode());
359 DIType T(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); }
367 const char *getFilename() const { return getCompileUnit().getFilename();}
368 const char *getDirectory() const { return getCompileUnit().getDirectory();}
370 /// Verify - Verify that a subprogram descriptor is well formed.
373 /// dump - print subprogram.
376 /// describes - Return true if this subprogram provides debugging
377 /// information for the function F.
378 bool describes(const Function *F);
381 /// DIGlobalVariable - This is a wrapper for a global variable.
382 class DIGlobalVariable : public DIGlobal {
384 explicit DIGlobalVariable(MDNode *N = 0)
385 : DIGlobal(N, dwarf::DW_TAG_variable) {}
387 GlobalVariable *getGlobal() const { return getGlobalVariableField(11); }
389 /// Verify - Verify that a global variable descriptor is well formed.
392 /// dump - print global variable.
396 /// DIVariable - This is a wrapper for a variable (e.g. parameter, local,
398 class DIVariable : public DIDescriptor {
400 explicit DIVariable(MDNode *N = 0)
402 if (DbgNode && !isVariable())
406 DIDescriptor getContext() const { return getDescriptorField(1); }
407 const char *getName() const { return getStringField(2); }
408 DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); }
409 unsigned getLineNumber() const { return getUnsignedField(4); }
410 DIType getType() const { return getFieldAs<DIType>(5); }
413 /// Verify - Verify that a variable descriptor is well formed.
416 /// HasComplexAddr - Return true if the variable has a complex address.
417 bool hasComplexAddress() const {
418 return getNumAddrElements() > 0;
421 unsigned getNumAddrElements() const { return DbgNode->getNumElements()-6; }
423 uint64_t getAddrElement(unsigned Idx) const {
424 return getUInt64Field(Idx+6);
427 /// isBlockByrefVariable - Return true if the variable was declared as
428 /// a "__block" variable (Apple Blocks).
429 bool isBlockByrefVariable() const {
430 return getType().isBlockByrefStruct();
433 /// dump - print variable.
437 /// DILexicalBlock - This is a wrapper for a lexical block.
438 class DILexicalBlock : public DIScope {
440 explicit DILexicalBlock(MDNode *N = 0) : DIScope(N) {
441 if (DbgNode && !isLexicalBlock())
444 DIScope getContext() const { return getFieldAs<DIScope>(1); }
445 const char *getDirectory() const { return getContext().getDirectory(); }
446 const char *getFilename() const { return getContext().getFilename(); }
449 /// DILocation - This object holds location information. This object
450 /// is not associated with any DWARF tag.
451 class DILocation : public DIDescriptor {
453 explicit DILocation(MDNode *N) : DIDescriptor(N) { ; }
455 unsigned getLineNumber() const { return getUnsignedField(0); }
456 unsigned getColumnNumber() const { return getUnsignedField(1); }
457 DIScope getScope() const { return getFieldAs<DIScope>(2); }
458 DILocation getOrigLocation() const { return getFieldAs<DILocation>(3); }
459 const char *getFilename() const { return getScope().getFilename(); }
460 const char *getDirectory() const { return getScope().getDirectory(); }
463 /// DIFactory - This object assists with the construction of the various
467 LLVMContext& VMContext;
469 // Cached values for uniquing and faster lookups.
470 const Type *EmptyStructPtr; // "{}*".
471 Function *StopPointFn; // llvm.dbg.stoppoint
472 Function *FuncStartFn; // llvm.dbg.func.start
473 Function *RegionStartFn; // llvm.dbg.region.start
474 Function *RegionEndFn; // llvm.dbg.region.end
475 Function *DeclareFn; // llvm.dbg.declare
476 StringMap<Constant*> StringCache;
477 DenseMap<Constant*, DIDescriptor> SimpleConstantCache;
479 DIFactory(const DIFactory &); // DO NOT IMPLEMENT
480 void operator=(const DIFactory&); // DO NOT IMPLEMENT
482 enum ComplexAddrKind { OpPlus=1, OpDeref };
484 explicit DIFactory(Module &m);
486 /// GetOrCreateArray - Create an descriptor for an array of descriptors.
487 /// This implicitly uniques the arrays created.
488 DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys);
490 /// GetOrCreateSubrange - Create a descriptor for a value range. This
491 /// implicitly uniques the values returned.
492 DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi);
494 /// CreateCompileUnit - Create a new descriptor for the specified compile
496 DICompileUnit CreateCompileUnit(unsigned LangID,
497 const char * Filename,
498 const char * Directory,
499 const char * Producer,
501 bool isOptimized = false,
502 const char *Flags = "",
503 unsigned RunTimeVer = 0);
505 /// CreateEnumerator - Create a single enumerator value.
506 DIEnumerator CreateEnumerator(const char * Name, uint64_t Val);
508 /// CreateBasicType - Create a basic type like int, float, etc.
509 DIBasicType CreateBasicType(DIDescriptor Context, const char * Name,
510 DICompileUnit CompileUnit, unsigned LineNumber,
511 uint64_t SizeInBits, uint64_t AlignInBits,
512 uint64_t OffsetInBits, unsigned Flags,
515 /// CreateBasicType - Create a basic type like int, float, etc.
516 DIBasicType CreateBasicTypeEx(DIDescriptor Context, const char * Name,
517 DICompileUnit CompileUnit, unsigned LineNumber,
518 Constant *SizeInBits, Constant *AlignInBits,
519 Constant *OffsetInBits, unsigned Flags,
522 /// CreateDerivedType - Create a derived type like const qualified type,
523 /// pointer, typedef, etc.
524 DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context,
526 DICompileUnit CompileUnit,
528 uint64_t SizeInBits, uint64_t AlignInBits,
529 uint64_t OffsetInBits, unsigned Flags,
532 /// CreateDerivedType - Create a derived type like const qualified type,
533 /// pointer, typedef, etc.
534 DIDerivedType CreateDerivedTypeEx(unsigned Tag, DIDescriptor Context,
536 DICompileUnit CompileUnit,
538 Constant *SizeInBits, Constant *AlignInBits,
539 Constant *OffsetInBits, unsigned Flags,
542 /// CreateCompositeType - Create a composite type like array, struct, etc.
543 DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context,
545 DICompileUnit CompileUnit,
548 uint64_t AlignInBits,
549 uint64_t OffsetInBits, unsigned Flags,
552 unsigned RunTimeLang = 0);
554 /// CreateCompositeType - Create a composite type like array, struct, etc.
555 DICompositeType CreateCompositeTypeEx(unsigned Tag, DIDescriptor Context,
557 DICompileUnit CompileUnit,
559 Constant *SizeInBits,
560 Constant *AlignInBits,
561 Constant *OffsetInBits, unsigned Flags,
564 unsigned RunTimeLang = 0);
566 /// CreateSubprogram - Create a new descriptor for the specified subprogram.
567 /// See comments in DISubprogram for descriptions of these fields.
568 DISubprogram CreateSubprogram(DIDescriptor Context, const char * Name,
569 const char * DisplayName,
570 const char * LinkageName,
571 DICompileUnit CompileUnit, unsigned LineNo,
572 DIType Type, bool isLocalToUnit,
575 /// CreateGlobalVariable - Create a new descriptor for the specified global.
577 CreateGlobalVariable(DIDescriptor Context, const char * Name,
578 const char * DisplayName,
579 const char * LinkageName,
580 DICompileUnit CompileUnit,
581 unsigned LineNo, DIType Type, bool isLocalToUnit,
582 bool isDefinition, llvm::GlobalVariable *GV);
584 /// CreateVariable - Create a new descriptor for the specified variable.
585 DIVariable CreateVariable(unsigned Tag, DIDescriptor Context,
587 DICompileUnit CompileUnit, unsigned LineNo,
590 /// CreateComplexVariable - Create a new descriptor for the specified
591 /// variable which has a complex address expression for its address.
592 DIVariable CreateComplexVariable(unsigned Tag, DIDescriptor Context,
593 const std::string &Name,
594 DICompileUnit CompileUnit, unsigned LineNo,
596 SmallVector<Value *, 9> &addr);
598 /// CreateLexicalBlock - This creates a descriptor for a lexical block
599 /// with the specified parent context.
600 DILexicalBlock CreateLexicalBlock(DIDescriptor Context);
602 /// CreateLocation - Creates a debug info location.
603 DILocation CreateLocation(unsigned LineNo, unsigned ColumnNo,
604 DIScope S, DILocation OrigLoc);
606 /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation,
607 /// inserting it at the end of the specified basic block.
608 void InsertStopPoint(DICompileUnit CU, unsigned LineNo, unsigned ColNo,
611 /// InsertSubprogramStart - Create a new llvm.dbg.func.start intrinsic to
612 /// mark the start of the specified subprogram.
613 void InsertSubprogramStart(DISubprogram SP, BasicBlock *BB);
615 /// InsertRegionStart - Insert a new llvm.dbg.region.start intrinsic call to
616 /// mark the start of a region for the specified scoping descriptor.
617 void InsertRegionStart(DIDescriptor D, BasicBlock *BB);
619 /// InsertRegionEnd - Insert a new llvm.dbg.region.end intrinsic call to
620 /// mark the end of a region for the specified scoping descriptor.
621 void InsertRegionEnd(DIDescriptor D, BasicBlock *BB);
623 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
624 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
625 BasicBlock *InsertAtEnd);
627 /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call.
628 Instruction *InsertDeclare(llvm::Value *Storage, DIVariable D,
629 Instruction *InsertBefore);
632 Constant *GetTagConstant(unsigned TAG);
635 /// Finds the stoppoint coressponding to this instruction, that is the
636 /// stoppoint that dominates this instruction
637 const DbgStopPointInst *findStopPoint(const Instruction *Inst);
639 /// Finds the stoppoint corresponding to first real (non-debug intrinsic)
640 /// instruction in this Basic Block, and returns the stoppoint for it.
641 const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB);
643 /// Finds the dbg.declare intrinsic corresponding to this value if any.
644 /// It looks through pointer casts too.
645 const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true);
647 /// Find the debug info descriptor corresponding to this global variable.
648 Value *findDbgGlobalDeclare(GlobalVariable *V);
650 bool getLocationInfo(const Value *V, std::string &DisplayName,
651 std::string &Type, unsigned &LineNo, std::string &File,
654 /// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug
656 bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI,
657 CodeGenOpt::Level OptLev);
659 /// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug
661 bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI,
662 CodeGenOpt::Level OptLev);
664 /// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug
666 bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI,
667 CodeGenOpt::Level OptLev);
669 /// isValidDebugInfoIntrinsic - Return true if REI is a valid debug
671 bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI,
672 CodeGenOpt::Level OptLev);
674 /// isValidDebugInfoIntrinsic - Return true if DI is a valid debug
676 bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI,
677 CodeGenOpt::Level OptLev);
679 /// ExtractDebugLocation - Extract debug location information
680 /// from llvm.dbg.stoppoint intrinsic.
681 DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI,
682 DebugLocTracker &DebugLocInfo);
684 /// ExtractDebugLocation - Extract debug location information
686 DebugLoc ExtractDebugLocation(DILocation &Loc,
687 DebugLocTracker &DebugLocInfo);
689 /// ExtractDebugLocation - Extract debug location information
690 /// from llvm.dbg.func_start intrinsic.
691 DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI,
692 DebugLocTracker &DebugLocInfo);
694 class DebugInfoFinder {
697 /// processModule - Process entire module and collect debug info
699 void processModule(Module &M);
702 /// processType - Process DIType.
703 void processType(DIType DT);
705 /// processLexicalBlock - Process DILexicalBlock.
706 void processLexicalBlock(DILexicalBlock LB);
708 /// processSubprogram - Process DISubprogram.
709 void processSubprogram(DISubprogram SP);
711 /// processDeclare - Process DbgDeclareInst.
712 void processDeclare(DbgDeclareInst *DDI);
714 /// processLocation - Process DILocation.
715 void processLocation(DILocation Loc);
717 /// addCompileUnit - Add compile unit into CUs.
718 bool addCompileUnit(DICompileUnit CU);
720 /// addGlobalVariable - Add global variable into GVs.
721 bool addGlobalVariable(DIGlobalVariable DIG);
723 // addSubprogram - Add subprgoram into SPs.
724 bool addSubprogram(DISubprogram SP);
726 /// addType - Add type into Tys.
727 bool addType(DIType DT);
730 typedef SmallVector<MDNode *, 8>::iterator iterator;
731 iterator compile_unit_begin() { return CUs.begin(); }
732 iterator compile_unit_end() { return CUs.end(); }
733 iterator subprogram_begin() { return SPs.begin(); }
734 iterator subprogram_end() { return SPs.end(); }
735 iterator global_variable_begin() { return GVs.begin(); }
736 iterator global_variable_end() { return GVs.end(); }
737 iterator type_begin() { return TYs.begin(); }
738 iterator type_end() { return TYs.end(); }
740 unsigned compile_unit_count() { return CUs.size(); }
741 unsigned global_variable_count() { return GVs.size(); }
742 unsigned subprogram_count() { return SPs.size(); }
743 unsigned type_count() { return TYs.size(); }
746 SmallVector<MDNode *, 8> CUs; // Compile Units
747 SmallVector<MDNode *, 8> SPs; // Subprograms
748 SmallVector<MDNode *, 8> GVs; // Global Variables;
749 SmallVector<MDNode *, 8> TYs; // Types
750 SmallPtrSet<MDNode *, 64> NodesSeen;
752 } // end namespace llvm