diff --git a/include/llvm/Analysis/DebugInfo.h b/include/llvm/Analysis/DebugInfo.h index 5ee8db6d163..29ea8be0c67 100644 --- a/include/llvm/Analysis/DebugInfo.h +++ b/include/llvm/Analysis/DebugInfo.h @@ -30,7 +30,7 @@ namespace llvm { class DbgStopPointInst; class DbgDeclareInst; class Instruction; - + class DIDescriptor { public: enum { @@ -40,29 +40,29 @@ namespace llvm { Version4 = 4 << 16, // Constant for version 4. VersionMask = 0xffff0000 // Mask for version number. }; - + protected: GlobalVariable *GV; - + /// DIDescriptor constructor. If the specified GV is non-null, this checks /// to make sure that the tag in the descriptor matches 'RequiredTag'. If /// not, the debug info is corrupt and we ignore it. DIDescriptor(GlobalVariable *GV, unsigned RequiredTag); - + std::string getStringField(unsigned Elt) const; unsigned getUnsignedField(unsigned Elt) const { return (unsigned)getUInt64Field(Elt); } uint64_t getUInt64Field(unsigned Elt) const; DIDescriptor getDescriptorField(unsigned Elt) const; - + template DescTy getFieldAs(unsigned Elt) const { return DescTy(getDescriptorField(Elt).getGV()); } - + GlobalVariable *getGlobalVariableField(unsigned Elt) const; - + public: explicit DIDescriptor() : GV(0) {} explicit DIDescriptor(GlobalVariable *gv) : GV(gv) {} @@ -74,18 +74,18 @@ namespace llvm { unsigned getVersion() const { return getUnsignedField(0) & VersionMask; } - + unsigned getTag() const { return getUnsignedField(0) & ~VersionMask; } - + }; - + /// DIAnchor - A wrapper for various anchor descriptors. class DIAnchor : public DIDescriptor { public: explicit DIAnchor(GlobalVariable *GV = 0); - + unsigned getAnchorTag() const { return getUnsignedField(1); } }; @@ -93,27 +93,27 @@ namespace llvm { class DISubrange : public DIDescriptor { public: explicit DISubrange(GlobalVariable *GV = 0); - + int64_t getLo() const { return (int64_t)getUInt64Field(1); } int64_t getHi() const { return (int64_t)getUInt64Field(2); } }; - + /// DIArray - This descriptor holds an array of descriptors. class DIArray : public DIDescriptor { public: explicit DIArray(GlobalVariable *GV = 0) : DIDescriptor(GV) {} - + unsigned getNumElements() const; DIDescriptor getElement(unsigned Idx) const { return getDescriptorField(Idx); } }; - + /// DICompileUnit - A wrapper for a compile unit. class DICompileUnit : public DIDescriptor { public: explicit DICompileUnit(GlobalVariable *GV = 0); - + unsigned getLanguage() const { return getUnsignedField(2); } std::string getFilename() const { return getStringField(3); } std::string getDirectory() const { return getStringField(4); } @@ -129,11 +129,11 @@ namespace llvm { class DIEnumerator : public DIDescriptor { public: explicit DIEnumerator(GlobalVariable *GV = 0); - + std::string getName() const { return getStringField(1); } uint64_t getEnumValue() const { return getUInt64Field(2); } }; - + /// DIType - This is a wrapper for a type. /// FIXME: Types should be factored much better so that CV qualifiers and /// others do not require a huge and empty descriptor full of zeros. @@ -187,17 +187,17 @@ namespace llvm { return ""; } }; - + /// DIBasicType - A basic type, like 'int' or 'float'. class DIBasicType : public DIType { public: explicit DIBasicType(GlobalVariable *GV); - + unsigned getEncoding() const { return getUnsignedField(9); } std::string getFilename() const { return getStringField(10); } std::string getDirectory() const { return getStringField(11); } }; - + /// DIDerivedType - A simple derived type, like a const qualified type, /// a typedef, a pointer or reference, etc. class DIDerivedType : public DIType { @@ -206,20 +206,19 @@ namespace llvm { : DIType(GV, true, true) {} public: explicit DIDerivedType(GlobalVariable *GV); - + DIType getTypeDerivedFrom() const { return getFieldAs(9); } std::string getFilename() const { return getStringField(10); } std::string getDirectory() const { return getStringField(11); } }; - /// DICompositeType - This descriptor holds a type that can refer to multiple /// other types, like a function or struct. /// FIXME: Why is this a DIDerivedType?? class DICompositeType : public DIDerivedType { public: explicit DICompositeType(GlobalVariable *GV); - + DIArray getTypeArray() const { return getFieldAs(10); } std::string getFilename() const { return getStringField(11); } std::string getDirectory() const { return getStringField(12); } @@ -227,7 +226,7 @@ namespace llvm { /// Verify - Verify that a composite type descriptor is well formed. bool Verify() const; }; - + /// DIGlobal - This is a common class for global variables and subprograms. class DIGlobal : public DIDescriptor { protected: @@ -253,11 +252,10 @@ namespace llvm { std::string getName() const { return getStringField(3); } std::string getDisplayName() const { return getStringField(4); } std::string getLinkageName() const { return getStringField(5); } - DICompileUnit getCompileUnit() const{ return getFieldAs(6); } unsigned getLineNumber() const { return getUnsignedField(7); } DIType getType() const { return getFieldAs(8); } - + /// isLocalToUnit - Return true if this subprogram is local to the current /// compile unit, like 'static' in C. unsigned isLocalToUnit() const { return getUnsignedField(9); } @@ -273,8 +271,7 @@ namespace llvm { return ""; } }; - - + /// DISubprogram - This is a wrapper for a subprogram (e.g. a function). class DISubprogram : public DIGlobal { public: @@ -286,12 +283,12 @@ namespace llvm { /// Verify - Verify that a subprogram descriptor is well formed. bool Verify() const; }; - + /// DIGlobalVariable - This is a wrapper for a global variable. class DIGlobalVariable : public DIGlobal { public: explicit DIGlobalVariable(GlobalVariable *GV = 0); - + GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } std::string getFilename() const { return getStringField(12); } std::string getDirectory() const { return getStringField(13); } @@ -299,31 +296,28 @@ namespace llvm { /// Verify - Verify that a global variable descriptor is well formed. bool Verify() const; }; - - + /// DIVariable - This is a wrapper for a variable (e.g. parameter, local, /// global etc). class DIVariable : public DIDescriptor { public: explicit DIVariable(GlobalVariable *GV = 0); - + DIDescriptor getContext() const { return getDescriptorField(1); } std::string getName() const { return getStringField(2); } - DICompileUnit getCompileUnit() const{ return getFieldAs(3); } unsigned getLineNumber() const { return getUnsignedField(4); } DIType getType() const { return getFieldAs(5); } std::string getFilename() const { return getStringField(6); } std::string getDirectory() const { return getStringField(7); } - + /// isVariable - Return true if the specified tag is legal for DIVariable. static bool isVariable(unsigned Tag); /// Verify - Verify that a variable descriptor is well formed. bool Verify() const; }; - - + /// DIBlock - This is a wrapper for a block (e.g. a function, scope, etc). class DIBlock : public DIDescriptor { public: @@ -331,7 +325,7 @@ namespace llvm { DIDescriptor getContext() const { return getDescriptorField(1); } }; - + /// DIFactory - This object assists with the construction of the various /// descriptors. class DIFactory { @@ -346,12 +340,12 @@ namespace llvm { Function *DeclareFn; // llvm.dbg.declare StringMap StringCache; DenseMap SimpleConstantCache; - + DIFactory(const DIFactory &); // DO NOT IMPLEMENT void operator=(const DIFactory&); // DO NOT IMPLEMENT public: explicit DIFactory(Module &m); - + /// GetOrCreateCompileUnitAnchor - Return the anchor for compile units, /// creating a new one if there isn't already one in the module. DIAnchor GetOrCreateCompileUnitAnchor(); @@ -371,8 +365,7 @@ namespace llvm { /// GetOrCreateSubrange - Create a descriptor for a value range. This /// implicitly uniques the values returned. DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); - - + /// CreateCompileUnit - Create a new descriptor for the specified compile /// unit. DICompileUnit CreateCompileUnit(unsigned LangID, @@ -382,7 +375,7 @@ namespace llvm { /// CreateEnumerator - Create a single enumerator value. DIEnumerator CreateEnumerator(const std::string &Name, uint64_t Val); - + /// CreateBasicType - Create a basic type like int, float, etc. DIBasicType CreateBasicType(DIDescriptor Context, const std::string &Name, DICompileUnit CompileUnit, unsigned LineNumber, @@ -391,7 +384,7 @@ namespace llvm { unsigned Encoding, const std::string *FileName = 0, const std::string *Directory = 0); - + /// CreateDerivedType - Create a derived type like const qualified type, /// pointer, typedef, etc. DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, @@ -416,7 +409,7 @@ namespace llvm { DIArray Elements, const std::string *FileName = 0, const std::string *Directory = 0); - + /// CreateSubprogram - Create a new descriptor for the specified subprogram. /// See comments in DISubprogram for descriptions of these fields. DISubprogram CreateSubprogram(DIDescriptor Context, const std::string &Name, @@ -438,8 +431,7 @@ namespace llvm { bool isDefinition, llvm::GlobalVariable *GV, const std::string *FileName = 0, const std::string *Directory = 0); - - + /// CreateVariable - Create a new descriptor for the specified variable. DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, const std::string &Name, @@ -447,16 +439,16 @@ namespace llvm { DIType Type, const std::string *FileName = 0, const std::string *Directory = 0); - + /// CreateBlock - This creates a descriptor for a lexical block with the /// specified parent context. DIBlock CreateBlock(DIDescriptor Context); - + /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation, /// inserting it at the end of the specified basic block. void InsertStopPoint(DICompileUnit CU, unsigned LineNo, unsigned ColNo, BasicBlock *BB); - + /// InsertSubprogramStart - Create a new llvm.dbg.func.start intrinsic to /// mark the start of the specified subprogram. void InsertSubprogramStart(DISubprogram SP, BasicBlock *BB); @@ -464,23 +456,23 @@ namespace llvm { /// InsertRegionStart - Insert a new llvm.dbg.region.start intrinsic call to /// mark the start of a region for the specified scoping descriptor. void InsertRegionStart(DIDescriptor D, BasicBlock *BB); - + /// InsertRegionEnd - Insert a new llvm.dbg.region.end intrinsic call to /// mark the end of a region for the specified scoping descriptor. void InsertRegionEnd(DIDescriptor D, BasicBlock *BB); - + /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. void InsertDeclare(llvm::Value *Storage, DIVariable D, BasicBlock *BB); - + private: Constant *GetTagConstant(unsigned TAG); Constant *GetStringConstant(const std::string &String); DIAnchor GetOrCreateAnchor(unsigned TAG, const char *Name); - + /// getCastToEmpty - Return the descriptor as a Constant* with type '{}*'. Constant *getCastToEmpty(DIDescriptor D); }; - + /// Finds the stoppoint coressponding to this instruction, that is the /// stoppoint that dominates this instruction const DbgStopPointInst *findStopPoint(const Instruction *Inst);