Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 1 | //===--- llvm/Analysis/DebugInfo.h - Debug Information Helpers --*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a bunch of datatypes that are useful for creating and |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 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 |
| 13 | // DWARF information. |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 14 | // |
| 15 | //===----------------------------------------------------------------------===// |
| 16 | |
Evan Cheng | 891415b | 2009-01-26 07:31:20 +0000 | [diff] [blame] | 17 | #ifndef LLVM_ANALYSIS_DEBUGINFO_H |
| 18 | #define LLVM_ANALYSIS_DEBUGINFO_H |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 19 | |
Argyrios Kyrtzidis | 77eaa68 | 2009-05-03 08:50:41 +0000 | [diff] [blame] | 20 | #include "llvm/Target/TargetMachine.h" |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 21 | #include "llvm/ADT/StringMap.h" |
| 22 | #include "llvm/ADT/DenseMap.h" |
Devang Patel | 13e16b6 | 2009-06-26 01:49:18 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/SmallVector.h" |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 24 | #include "llvm/Support/Dwarf.h" |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 25 | |
| 26 | namespace llvm { |
| 27 | class BasicBlock; |
| 28 | class Constant; |
| 29 | class Function; |
| 30 | class GlobalVariable; |
| 31 | class Module; |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 32 | class Type; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 33 | class Value; |
Cedric Venet | aff9c27 | 2009-02-14 16:06:42 +0000 | [diff] [blame] | 34 | struct DbgStopPointInst; |
| 35 | struct DbgDeclareInst; |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 36 | struct DbgFuncStartInst; |
| 37 | struct DbgRegionStartInst; |
| 38 | struct DbgRegionEndInst; |
| 39 | class DebugLoc; |
| 40 | class DebugLocTracker; |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 41 | class Instruction; |
Owen Anderson | 9903527 | 2009-07-07 17:12:53 +0000 | [diff] [blame^] | 42 | class LLVMContext; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 43 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 44 | class DIDescriptor { |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 45 | protected: |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 46 | GlobalVariable *DbgGV; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 47 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 48 | /// DIDescriptor constructor. If the specified GV is non-null, this checks |
| 49 | /// to make sure that the tag in the descriptor matches 'RequiredTag'. If |
| 50 | /// not, the debug info is corrupt and we ignore it. |
| 51 | DIDescriptor(GlobalVariable *GV, unsigned RequiredTag); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 52 | |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 53 | const std::string &getStringField(unsigned Elt, std::string &Result) const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 54 | unsigned getUnsignedField(unsigned Elt) const { |
| 55 | return (unsigned)getUInt64Field(Elt); |
| 56 | } |
| 57 | uint64_t getUInt64Field(unsigned Elt) const; |
| 58 | DIDescriptor getDescriptorField(unsigned Elt) const; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 59 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 60 | template <typename DescTy> |
| 61 | DescTy getFieldAs(unsigned Elt) const { |
Torok Edwin | b07fbd9 | 2008-12-13 08:25:29 +0000 | [diff] [blame] | 62 | return DescTy(getDescriptorField(Elt).getGV()); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 63 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 64 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 65 | GlobalVariable *getGlobalVariableField(unsigned Elt) const; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 66 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 67 | public: |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 68 | explicit DIDescriptor() : DbgGV(0) {} |
| 69 | explicit DIDescriptor(GlobalVariable *GV) : DbgGV(GV) {} |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 70 | |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 71 | bool isNull() const { return DbgGV == 0; } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 72 | |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 73 | GlobalVariable *getGV() const { return DbgGV; } |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 74 | |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 75 | unsigned getVersion() const { |
Devang Patel | 6906ba5 | 2009-01-20 19:22:03 +0000 | [diff] [blame] | 76 | return getUnsignedField(0) & LLVMDebugVersionMask; |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 77 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 78 | |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 79 | unsigned getTag() const { |
Devang Patel | 6906ba5 | 2009-01-20 19:22:03 +0000 | [diff] [blame] | 80 | return getUnsignedField(0) & ~LLVMDebugVersionMask; |
Devang Patel | 2c1623a | 2009-01-05 18:06:21 +0000 | [diff] [blame] | 81 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 82 | |
Argyrios Kyrtzidis | 77eaa68 | 2009-05-03 08:50:41 +0000 | [diff] [blame] | 83 | /// ValidDebugInfo - Return true if V represents valid debug info value. |
| 84 | static bool ValidDebugInfo(Value *V, CodeGenOpt::Level OptLevel); |
| 85 | |
Bill Wendling | 16de013 | 2009-05-05 22:19:25 +0000 | [diff] [blame] | 86 | /// dump - print descriptor. |
| 87 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 88 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 89 | |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 90 | /// DISubrange - This is used to represent ranges, for array bounds. |
| 91 | class DISubrange : public DIDescriptor { |
| 92 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 93 | explicit DISubrange(GlobalVariable *GV = 0) |
| 94 | : DIDescriptor(GV, dwarf::DW_TAG_subrange_type) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 95 | |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 96 | int64_t getLo() const { return (int64_t)getUInt64Field(1); } |
| 97 | int64_t getHi() const { return (int64_t)getUInt64Field(2); } |
| 98 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 99 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 100 | /// DIArray - This descriptor holds an array of descriptors. |
| 101 | class DIArray : public DIDescriptor { |
| 102 | public: |
| 103 | explicit DIArray(GlobalVariable *GV = 0) : DIDescriptor(GV) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 104 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 105 | unsigned getNumElements() const; |
Devang Patel | a22d57d | 2009-01-05 19:55:07 +0000 | [diff] [blame] | 106 | DIDescriptor getElement(unsigned Idx) const { |
| 107 | return getDescriptorField(Idx); |
Devang Patel | 68afdc3 | 2009-01-05 18:33:01 +0000 | [diff] [blame] | 108 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 109 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 110 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 111 | /// DICompileUnit - A wrapper for a compile unit. |
| 112 | class DICompileUnit : public DIDescriptor { |
| 113 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 114 | explicit DICompileUnit(GlobalVariable *GV = 0) |
| 115 | : DIDescriptor(GV, dwarf::DW_TAG_compile_unit) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 116 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 117 | unsigned getLanguage() const { return getUnsignedField(2); } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 118 | const std::string &getFilename(std::string &F) const { |
| 119 | return getStringField(3, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 120 | } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 121 | const std::string &getDirectory(std::string &F) const { |
| 122 | return getStringField(4, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 123 | } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 124 | const std::string &getProducer(std::string &F) const { |
| 125 | return getStringField(5, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 126 | } |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 127 | |
| 128 | /// isMain - Each input file is encoded as a separate compile unit in LLVM |
| 129 | /// debugging information output. However, many target specific tool chains |
| 130 | /// prefer to encode only one compile unit in an object file. In this |
| 131 | /// situation, the LLVM code generator will include debugging information |
| 132 | /// entities in the compile unit that is marked as main compile unit. The |
| 133 | /// code generator accepts maximum one main compile unit per module. If a |
| 134 | /// module does not contain any main compile unit then the code generator |
| 135 | /// will emit multiple compile units in the output object file. |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 136 | |
Devang Patel | 36375ee | 2009-02-17 21:23:59 +0000 | [diff] [blame] | 137 | bool isMain() const { return getUnsignedField(6); } |
| 138 | bool isOptimized() const { return getUnsignedField(7); } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 139 | const std::string &getFlags(std::string &F) const { |
| 140 | return getStringField(8, F); |
| 141 | } |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 142 | unsigned getRunTimeVersion() const { return getUnsignedField(9); } |
Devang Patel | ce31b02 | 2009-01-20 18:13:03 +0000 | [diff] [blame] | 143 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 144 | /// Verify - Verify that a compile unit is well formed. |
| 145 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 146 | |
| 147 | /// dump - print compile unit. |
| 148 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 149 | }; |
| 150 | |
| 151 | /// DIEnumerator - A wrapper for an enumerator (e.g. X and Y in 'enum {X,Y}'). |
| 152 | /// FIXME: it seems strange that this doesn't have either a reference to the |
| 153 | /// type/precision or a file/line pair for location info. |
| 154 | class DIEnumerator : public DIDescriptor { |
| 155 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 156 | explicit DIEnumerator(GlobalVariable *GV = 0) |
| 157 | : DIDescriptor(GV, dwarf::DW_TAG_enumerator) {} |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 158 | |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 159 | const std::string &getName(std::string &F) const { |
| 160 | return getStringField(1, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 161 | } |
Devang Patel | c69bf2c | 2009-01-05 18:38:38 +0000 | [diff] [blame] | 162 | uint64_t getEnumValue() const { return getUInt64Field(2); } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 163 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 164 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 165 | /// DIType - This is a wrapper for a type. |
| 166 | /// FIXME: Types should be factored much better so that CV qualifiers and |
| 167 | /// others do not require a huge and empty descriptor full of zeros. |
| 168 | class DIType : public DIDescriptor { |
Devang Patel | 2a57466 | 2009-01-20 22:27:02 +0000 | [diff] [blame] | 169 | public: |
| 170 | enum { |
| 171 | FlagPrivate = 1 << 0, |
| 172 | FlagProtected = 1 << 1, |
Devang Patel | 4766159 | 2009-01-21 00:08:04 +0000 | [diff] [blame] | 173 | FlagFwdDecl = 1 << 2 |
Devang Patel | 2a57466 | 2009-01-20 22:27:02 +0000 | [diff] [blame] | 174 | }; |
| 175 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 176 | protected: |
| 177 | DIType(GlobalVariable *GV, unsigned Tag) : DIDescriptor(GV, Tag) {} |
| 178 | // This ctor is used when the Tag has already been validated by a derived |
| 179 | // ctor. |
| 180 | DIType(GlobalVariable *GV, bool, bool) : DIDescriptor(GV) {} |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 181 | |
Devang Patel | f193ff0 | 2009-01-15 19:26:23 +0000 | [diff] [blame] | 182 | public: |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 183 | /// isDerivedType - Return true if the specified tag is legal for |
| 184 | /// DIDerivedType. |
| 185 | static bool isDerivedType(unsigned TAG); |
| 186 | |
| 187 | /// isCompositeType - Return true if the specified tag is legal for |
| 188 | /// DICompositeType. |
| 189 | static bool isCompositeType(unsigned TAG); |
| 190 | |
| 191 | /// isBasicType - Return true if the specified tag is legal for |
| 192 | /// DIBasicType. |
| 193 | static bool isBasicType(unsigned TAG) { |
| 194 | return TAG == dwarf::DW_TAG_base_type; |
| 195 | } |
| 196 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 197 | /// Verify - Verify that a type descriptor is well formed. |
| 198 | bool Verify() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 199 | public: |
| 200 | explicit DIType(GlobalVariable *GV); |
| 201 | explicit DIType() {} |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 202 | virtual ~DIType() {} |
| 203 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 204 | DIDescriptor getContext() const { return getDescriptorField(1); } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 205 | const std::string &getName(std::string &F) const { |
| 206 | return getStringField(2, F); |
| 207 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 208 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); } |
| 209 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 210 | uint64_t getSizeInBits() const { return getUInt64Field(5); } |
| 211 | uint64_t getAlignInBits() const { return getUInt64Field(6); } |
| 212 | // FIXME: Offset is only used for DW_TAG_member nodes. Making every type |
| 213 | // carry this is just plain insane. |
| 214 | uint64_t getOffsetInBits() const { return getUInt64Field(7); } |
| 215 | unsigned getFlags() const { return getUnsignedField(8); } |
Devang Patel | 2a57466 | 2009-01-20 22:27:02 +0000 | [diff] [blame] | 216 | bool isPrivate() const { return (getFlags() & FlagPrivate) != 0; } |
| 217 | bool isProtected() const { return (getFlags() & FlagProtected) != 0; } |
| 218 | bool isForwardDecl() const { return (getFlags() & FlagFwdDecl) != 0; } |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 219 | |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 220 | /// dump - print type. |
| 221 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 222 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 223 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 224 | /// DIBasicType - A basic type, like 'int' or 'float'. |
| 225 | class DIBasicType : public DIType { |
| 226 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 227 | explicit DIBasicType(GlobalVariable *GV) |
| 228 | : DIType(GV, dwarf::DW_TAG_base_type) {} |
| 229 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 230 | unsigned getEncoding() const { return getUnsignedField(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 231 | |
| 232 | /// dump - print basic type. |
| 233 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 234 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 235 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 236 | /// DIDerivedType - A simple derived type, like a const qualified type, |
| 237 | /// a typedef, a pointer or reference, etc. |
| 238 | class DIDerivedType : public DIType { |
| 239 | protected: |
| 240 | explicit DIDerivedType(GlobalVariable *GV, bool, bool) |
| 241 | : DIType(GV, true, true) {} |
| 242 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 243 | explicit DIDerivedType(GlobalVariable *GV) |
| 244 | : DIType(GV, true, true) { |
| 245 | if (GV && !isDerivedType(getTag())) |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 246 | DbgGV = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 249 | DIType getTypeDerivedFrom() const { return getFieldAs<DIType>(9); } |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 250 | |
Devang Patel | 36375ee | 2009-02-17 21:23:59 +0000 | [diff] [blame] | 251 | /// getOriginalTypeSize - If this type is derived from a base type then |
| 252 | /// return base type size. |
| 253 | uint64_t getOriginalTypeSize() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 254 | /// dump - print derived type. |
| 255 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 256 | }; |
| 257 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 258 | /// DICompositeType - This descriptor holds a type that can refer to multiple |
| 259 | /// other types, like a function or struct. |
| 260 | /// FIXME: Why is this a DIDerivedType?? |
| 261 | class DICompositeType : public DIDerivedType { |
| 262 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 263 | explicit DICompositeType(GlobalVariable *GV) |
| 264 | : DIDerivedType(GV, true, true) { |
| 265 | if (GV && !isCompositeType(getTag())) |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 266 | DbgGV = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 267 | } |
| 268 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 269 | DIArray getTypeArray() const { return getFieldAs<DIArray>(10); } |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 270 | unsigned getRunTimeLang() const { return getUnsignedField(11); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 271 | |
| 272 | /// Verify - Verify that a composite type descriptor is well formed. |
| 273 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 274 | |
| 275 | /// dump - print composite type. |
| 276 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 277 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 278 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 279 | /// DIGlobal - This is a common class for global variables and subprograms. |
| 280 | class DIGlobal : public DIDescriptor { |
| 281 | protected: |
Chris Lattner | 3b78185 | 2008-11-10 03:11:39 +0000 | [diff] [blame] | 282 | explicit DIGlobal(GlobalVariable *GV, unsigned RequiredTag) |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 283 | : DIDescriptor(GV, RequiredTag) {} |
Devang Patel | 486938f | 2009-01-12 21:38:43 +0000 | [diff] [blame] | 284 | |
| 285 | /// isSubprogram - Return true if the specified tag is legal for |
| 286 | /// DISubprogram. |
| 287 | static bool isSubprogram(unsigned TAG) { |
| 288 | return TAG == dwarf::DW_TAG_subprogram; |
| 289 | } |
| 290 | |
| 291 | /// isGlobalVariable - Return true if the specified tag is legal for |
| 292 | /// DIGlobalVariable. |
| 293 | static bool isGlobalVariable(unsigned TAG) { |
| 294 | return TAG == dwarf::DW_TAG_variable; |
| 295 | } |
| 296 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 297 | public: |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 298 | virtual ~DIGlobal() {} |
| 299 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 300 | DIDescriptor getContext() const { return getDescriptorField(2); } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 301 | const std::string &getName(std::string &F) const { |
| 302 | return getStringField(3, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 303 | } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 304 | const std::string &getDisplayName(std::string &F) const { |
| 305 | return getStringField(4, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 306 | } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 307 | const std::string &getLinkageName(std::string &F) const { |
| 308 | return getStringField(5, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 309 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 310 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(6); } |
| 311 | unsigned getLineNumber() const { return getUnsignedField(7); } |
| 312 | DIType getType() const { return getFieldAs<DIType>(8); } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 313 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 314 | /// isLocalToUnit - Return true if this subprogram is local to the current |
| 315 | /// compile unit, like 'static' in C. |
| 316 | unsigned isLocalToUnit() const { return getUnsignedField(9); } |
| 317 | unsigned isDefinition() const { return getUnsignedField(10); } |
Devang Patel | 8526cc0 | 2009-01-05 22:35:52 +0000 | [diff] [blame] | 318 | |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 319 | /// dump - print global. |
| 320 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 321 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 322 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 323 | /// DISubprogram - This is a wrapper for a subprogram (e.g. a function). |
| 324 | class DISubprogram : public DIGlobal { |
| 325 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 326 | explicit DISubprogram(GlobalVariable *GV = 0) |
| 327 | : DIGlobal(GV, dwarf::DW_TAG_subprogram) {} |
| 328 | |
Devang Patel | 86ae142 | 2009-01-05 18:59:44 +0000 | [diff] [blame] | 329 | DICompositeType getType() const { return getFieldAs<DICompositeType>(8); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 330 | |
Devang Patel | 0de4fa6 | 2009-06-23 22:07:48 +0000 | [diff] [blame] | 331 | /// getReturnTypeName - Subprogram return types are encoded either as |
| 332 | /// DIType or as DICompositeType. |
| 333 | const std::string &getReturnTypeName(std::string &F) const { |
| 334 | DICompositeType DCT(getFieldAs<DICompositeType>(8)); |
| 335 | if (!DCT.isNull()) { |
| 336 | DIArray A = DCT.getTypeArray(); |
| 337 | DIType T(A.getElement(0).getGV()); |
| 338 | return T.getName(F); |
| 339 | } |
| 340 | DIType T(getFieldAs<DIType>(8)); |
| 341 | return T.getName(F); |
| 342 | } |
| 343 | |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 344 | /// Verify - Verify that a subprogram descriptor is well formed. |
| 345 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 346 | |
| 347 | /// dump - print subprogram. |
| 348 | void dump() const; |
Devang Patel | af5b6bb | 2009-04-15 00:06:07 +0000 | [diff] [blame] | 349 | |
| 350 | /// describes - Return true if this subprogram provides debugging |
| 351 | /// information for the function F. |
| 352 | bool describes(const Function *F); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 353 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 354 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 355 | /// DIGlobalVariable - This is a wrapper for a global variable. |
| 356 | class DIGlobalVariable : public DIGlobal { |
| 357 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 358 | explicit DIGlobalVariable(GlobalVariable *GV = 0) |
| 359 | : DIGlobal(GV, dwarf::DW_TAG_variable) {} |
| 360 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 361 | GlobalVariable *getGlobal() const { return getGlobalVariableField(11); } |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 362 | |
| 363 | /// Verify - Verify that a global variable descriptor is well formed. |
| 364 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 365 | |
| 366 | /// dump - print global variable. |
| 367 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 368 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 369 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 370 | /// DIVariable - This is a wrapper for a variable (e.g. parameter, local, |
| 371 | /// global etc). |
| 372 | class DIVariable : public DIDescriptor { |
| 373 | public: |
Devang Patel | 9af2fa8 | 2009-06-23 22:25:41 +0000 | [diff] [blame] | 374 | explicit DIVariable(GlobalVariable *GV = 0) |
| 375 | : DIDescriptor(GV) { |
| 376 | if (GV && !isVariable(getTag())) |
| 377 | DbgGV = 0; |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 378 | } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 379 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 380 | DIDescriptor getContext() const { return getDescriptorField(1); } |
Bill Wendling | 0582ae9 | 2009-03-13 04:39:26 +0000 | [diff] [blame] | 381 | const std::string &getName(std::string &F) const { |
| 382 | return getStringField(2, F); |
Bill Wendling | ccbdc7a | 2009-03-09 05:04:40 +0000 | [diff] [blame] | 383 | } |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 384 | DICompileUnit getCompileUnit() const{ return getFieldAs<DICompileUnit>(3); } |
| 385 | unsigned getLineNumber() const { return getUnsignedField(4); } |
| 386 | DIType getType() const { return getFieldAs<DIType>(5); } |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 387 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 388 | /// isVariable - Return true if the specified tag is legal for DIVariable. |
| 389 | static bool isVariable(unsigned Tag); |
Devang Patel | b79b535 | 2009-01-19 23:21:49 +0000 | [diff] [blame] | 390 | |
| 391 | /// Verify - Verify that a variable descriptor is well formed. |
| 392 | bool Verify() const; |
Devang Patel | bf3f5a0 | 2009-01-30 01:03:10 +0000 | [diff] [blame] | 393 | |
| 394 | /// dump - print variable. |
| 395 | void dump() const; |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 396 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 397 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 398 | /// DIBlock - This is a wrapper for a block (e.g. a function, scope, etc). |
| 399 | class DIBlock : public DIDescriptor { |
| 400 | public: |
Bill Wendling | dc817b6 | 2009-05-14 18:26:15 +0000 | [diff] [blame] | 401 | explicit DIBlock(GlobalVariable *GV = 0) |
| 402 | : DIDescriptor(GV, dwarf::DW_TAG_lexical_block) {} |
| 403 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 404 | DIDescriptor getContext() const { return getDescriptorField(1); } |
| 405 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 406 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 407 | /// DIFactory - This object assists with the construction of the various |
| 408 | /// descriptors. |
| 409 | class DIFactory { |
| 410 | Module &M; |
Owen Anderson | 9903527 | 2009-07-07 17:12:53 +0000 | [diff] [blame^] | 411 | LLVMContext& VMContext; |
| 412 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 413 | // Cached values for uniquing and faster lookups. |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 414 | const Type *EmptyStructPtr; // "{}*". |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 415 | Function *StopPointFn; // llvm.dbg.stoppoint |
| 416 | Function *FuncStartFn; // llvm.dbg.func.start |
| 417 | Function *RegionStartFn; // llvm.dbg.region.start |
| 418 | Function *RegionEndFn; // llvm.dbg.region.end |
| 419 | Function *DeclareFn; // llvm.dbg.declare |
| 420 | StringMap<Constant*> StringCache; |
| 421 | DenseMap<Constant*, DIDescriptor> SimpleConstantCache; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 422 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 423 | DIFactory(const DIFactory &); // DO NOT IMPLEMENT |
| 424 | void operator=(const DIFactory&); // DO NOT IMPLEMENT |
| 425 | public: |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 426 | explicit DIFactory(Module &m); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 427 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 428 | /// GetOrCreateArray - Create an descriptor for an array of descriptors. |
| 429 | /// This implicitly uniques the arrays created. |
| 430 | DIArray GetOrCreateArray(DIDescriptor *Tys, unsigned NumTys); |
| 431 | |
| 432 | /// GetOrCreateSubrange - Create a descriptor for a value range. This |
| 433 | /// implicitly uniques the values returned. |
| 434 | DISubrange GetOrCreateSubrange(int64_t Lo, int64_t Hi); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 435 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 436 | /// CreateCompileUnit - Create a new descriptor for the specified compile |
| 437 | /// unit. |
| 438 | DICompileUnit CreateCompileUnit(unsigned LangID, |
| 439 | const std::string &Filename, |
| 440 | const std::string &Directory, |
Devang Patel | 3b64c6b | 2009-01-23 22:33:47 +0000 | [diff] [blame] | 441 | const std::string &Producer, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 442 | bool isMain = false, |
Devang Patel | 3b64c6b | 2009-01-23 22:33:47 +0000 | [diff] [blame] | 443 | bool isOptimized = false, |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 444 | const char *Flags = "", |
| 445 | unsigned RunTimeVer = 0); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 446 | |
| 447 | /// CreateEnumerator - Create a single enumerator value. |
| 448 | DIEnumerator CreateEnumerator(const std::string &Name, uint64_t Val); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 449 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 450 | /// CreateBasicType - Create a basic type like int, float, etc. |
| 451 | DIBasicType CreateBasicType(DIDescriptor Context, const std::string &Name, |
| 452 | DICompileUnit CompileUnit, unsigned LineNumber, |
| 453 | uint64_t SizeInBits, uint64_t AlignInBits, |
| 454 | uint64_t OffsetInBits, unsigned Flags, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 455 | unsigned Encoding); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 456 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 457 | /// CreateDerivedType - Create a derived type like const qualified type, |
| 458 | /// pointer, typedef, etc. |
| 459 | DIDerivedType CreateDerivedType(unsigned Tag, DIDescriptor Context, |
| 460 | const std::string &Name, |
| 461 | DICompileUnit CompileUnit, |
| 462 | unsigned LineNumber, |
| 463 | uint64_t SizeInBits, uint64_t AlignInBits, |
| 464 | uint64_t OffsetInBits, unsigned Flags, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 465 | DIType DerivedFrom); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 466 | |
| 467 | /// CreateCompositeType - Create a composite type like array, struct, etc. |
| 468 | DICompositeType CreateCompositeType(unsigned Tag, DIDescriptor Context, |
| 469 | const std::string &Name, |
| 470 | DICompileUnit CompileUnit, |
| 471 | unsigned LineNumber, |
| 472 | uint64_t SizeInBits, |
| 473 | uint64_t AlignInBits, |
| 474 | uint64_t OffsetInBits, unsigned Flags, |
| 475 | DIType DerivedFrom, |
Devang Patel | 13319ce | 2009-02-17 22:43:44 +0000 | [diff] [blame] | 476 | DIArray Elements, |
| 477 | unsigned RunTimeLang = 0); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 478 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 479 | /// CreateSubprogram - Create a new descriptor for the specified subprogram. |
| 480 | /// See comments in DISubprogram for descriptions of these fields. |
| 481 | DISubprogram CreateSubprogram(DIDescriptor Context, const std::string &Name, |
| 482 | const std::string &DisplayName, |
| 483 | const std::string &LinkageName, |
| 484 | DICompileUnit CompileUnit, unsigned LineNo, |
| 485 | DIType Type, bool isLocalToUnit, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 486 | bool isDefinition); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 487 | |
| 488 | /// CreateGlobalVariable - Create a new descriptor for the specified global. |
| 489 | DIGlobalVariable |
| 490 | CreateGlobalVariable(DIDescriptor Context, const std::string &Name, |
| 491 | const std::string &DisplayName, |
| 492 | const std::string &LinkageName, |
| 493 | DICompileUnit CompileUnit, |
| 494 | unsigned LineNo, DIType Type, bool isLocalToUnit, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 495 | bool isDefinition, llvm::GlobalVariable *GV); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 496 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 497 | /// CreateVariable - Create a new descriptor for the specified variable. |
| 498 | DIVariable CreateVariable(unsigned Tag, DIDescriptor Context, |
| 499 | const std::string &Name, |
| 500 | DICompileUnit CompileUnit, unsigned LineNo, |
Devang Patel | dd9db66 | 2009-01-30 18:20:31 +0000 | [diff] [blame] | 501 | DIType Type); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 502 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 503 | /// CreateBlock - This creates a descriptor for a lexical block with the |
| 504 | /// specified parent context. |
| 505 | DIBlock CreateBlock(DIDescriptor Context); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 506 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 507 | /// InsertStopPoint - Create a new llvm.dbg.stoppoint intrinsic invocation, |
| 508 | /// inserting it at the end of the specified basic block. |
| 509 | void InsertStopPoint(DICompileUnit CU, unsigned LineNo, unsigned ColNo, |
| 510 | BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 511 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 512 | /// InsertSubprogramStart - Create a new llvm.dbg.func.start intrinsic to |
| 513 | /// mark the start of the specified subprogram. |
| 514 | void InsertSubprogramStart(DISubprogram SP, BasicBlock *BB); |
| 515 | |
| 516 | /// InsertRegionStart - Insert a new llvm.dbg.region.start intrinsic call to |
| 517 | /// mark the start of a region for the specified scoping descriptor. |
| 518 | void InsertRegionStart(DIDescriptor D, BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 519 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 520 | /// InsertRegionEnd - Insert a new llvm.dbg.region.end intrinsic call to |
| 521 | /// mark the end of a region for the specified scoping descriptor. |
| 522 | void InsertRegionEnd(DIDescriptor D, BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 523 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 524 | /// InsertDeclare - Insert a new llvm.dbg.declare intrinsic call. |
| 525 | void InsertDeclare(llvm::Value *Storage, DIVariable D, BasicBlock *BB); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 526 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 527 | private: |
| 528 | Constant *GetTagConstant(unsigned TAG); |
| 529 | Constant *GetStringConstant(const std::string &String); |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 530 | |
Chris Lattner | 497a7a8 | 2008-11-10 04:10:34 +0000 | [diff] [blame] | 531 | /// getCastToEmpty - Return the descriptor as a Constant* with type '{}*'. |
| 532 | Constant *getCastToEmpty(DIDescriptor D); |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 533 | }; |
Devang Patel | a913f4f | 2009-01-20 19:08:39 +0000 | [diff] [blame] | 534 | |
Torok Edwin | 620f280 | 2008-12-16 09:07:36 +0000 | [diff] [blame] | 535 | /// Finds the stoppoint coressponding to this instruction, that is the |
| 536 | /// stoppoint that dominates this instruction |
| 537 | const DbgStopPointInst *findStopPoint(const Instruction *Inst); |
| 538 | |
| 539 | /// Finds the stoppoint corresponding to first real (non-debug intrinsic) |
| 540 | /// instruction in this Basic Block, and returns the stoppoint for it. |
| 541 | const DbgStopPointInst *findBBStopPoint(const BasicBlock *BB); |
| 542 | |
| 543 | /// Finds the dbg.declare intrinsic corresponding to this value if any. |
| 544 | /// It looks through pointer casts too. |
| 545 | const DbgDeclareInst *findDbgDeclare(const Value *V, bool stripCasts = true); |
Torok Edwin | ff7d0e9 | 2009-03-10 13:41:26 +0000 | [diff] [blame] | 546 | |
| 547 | /// Find the debug info descriptor corresponding to this global variable. |
| 548 | Value *findDbgGlobalDeclare(GlobalVariable *V); |
| 549 | |
| 550 | bool getLocationInfo(const Value *V, std::string &DisplayName, std::string &Type, |
| 551 | unsigned &LineNo, std::string &File, std::string &Dir); |
Devang Patel | 13e16b6 | 2009-06-26 01:49:18 +0000 | [diff] [blame] | 552 | |
| 553 | /// CollectDebugInfoAnchors - Collect debugging information anchors. |
| 554 | void CollectDebugInfoAnchors(Module &M, |
| 555 | SmallVector<GlobalVariable *, 2> &CompileUnits, |
| 556 | SmallVector<GlobalVariable *, 4> &GlobalVars, |
| 557 | SmallVector<GlobalVariable *, 4> &Subprograms); |
| 558 | |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 559 | /// isValidDebugInfoIntrinsic - Return true if SPI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 560 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 561 | bool isValidDebugInfoIntrinsic(DbgStopPointInst &SPI, |
| 562 | CodeGenOpt::Level OptLev); |
| 563 | |
| 564 | /// isValidDebugInfoIntrinsic - Return true if FSI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 565 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 566 | bool isValidDebugInfoIntrinsic(DbgFuncStartInst &FSI, |
| 567 | CodeGenOpt::Level OptLev); |
| 568 | |
| 569 | /// isValidDebugInfoIntrinsic - Return true if RSI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 570 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 571 | bool isValidDebugInfoIntrinsic(DbgRegionStartInst &RSI, |
| 572 | CodeGenOpt::Level OptLev); |
| 573 | |
| 574 | /// isValidDebugInfoIntrinsic - Return true if REI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 575 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 576 | bool isValidDebugInfoIntrinsic(DbgRegionEndInst &REI, |
| 577 | CodeGenOpt::Level OptLev); |
| 578 | |
| 579 | /// isValidDebugInfoIntrinsic - Return true if DI is a valid debug |
Devang Patel | dfc8536 | 2009-07-02 17:17:03 +0000 | [diff] [blame] | 580 | /// info intrinsic. |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 581 | bool isValidDebugInfoIntrinsic(DbgDeclareInst &DI, |
| 582 | CodeGenOpt::Level OptLev); |
| 583 | |
| 584 | /// ExtractDebugLocation - Extract debug location information |
| 585 | /// from llvm.dbg.stoppoint intrinsic. |
| 586 | DebugLoc ExtractDebugLocation(DbgStopPointInst &SPI, |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 587 | DebugLocTracker &DebugLocInfo); |
| 588 | |
| 589 | /// ExtractDebugLocation - Extract debug location information |
| 590 | /// from llvm.dbg.func_start intrinsic. |
| 591 | DebugLoc ExtractDebugLocation(DbgFuncStartInst &FSI, |
Devang Patel | 9e529c3 | 2009-07-02 01:15:24 +0000 | [diff] [blame] | 592 | DebugLocTracker &DebugLocInfo); |
| 593 | |
| 594 | /// isInlinedFnStart - Return true if FSI is starting an inlined function. |
| 595 | bool isInlinedFnStart(DbgFuncStartInst &FSI, const Function *CurrentFn); |
| 596 | |
| 597 | /// isInlinedFnEnd - Return true if REI is ending an inlined function. |
| 598 | bool isInlinedFnEnd(DbgRegionEndInst &REI, const Function *CurrentFn); |
| 599 | |
Chris Lattner | a45664f | 2008-11-10 02:56:27 +0000 | [diff] [blame] | 600 | } // end namespace llvm |
| 601 | |
| 602 | #endif |