Reid Kleckner | 70f5bc9 | 2016-01-14 19:25:04 +0000 | [diff] [blame] | 1 | //===-- llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.h ----*- C++ -*--===// |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 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 | // |
Reid Kleckner | 70f5bc9 | 2016-01-14 19:25:04 +0000 | [diff] [blame] | 10 | // This file contains support for writing Microsoft CodeView debug info. |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Reid Kleckner | 70f5bc9 | 2016-01-14 19:25:04 +0000 | [diff] [blame] | 14 | #ifndef LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H |
| 15 | #define LLVM_LIB_CODEGEN_ASMPRINTER_CODEVIEWDEBUG_H |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 16 | |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 17 | #include "DebugHandlerBase.h" |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/DenseMap.h" |
| 19 | #include "llvm/ADT/StringMap.h" |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 20 | #include "llvm/CodeGen/AsmPrinter.h" |
| 21 | #include "llvm/CodeGen/MachineFunction.h" |
| 22 | #include "llvm/CodeGen/MachineModuleInfo.h" |
Reid Kleckner | 2280f93 | 2016-05-23 20:23:46 +0000 | [diff] [blame] | 23 | #include "llvm/DebugInfo/CodeView/MemoryTypeTableBuilder.h" |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 24 | #include "llvm/DebugInfo/CodeView/TypeIndex.h" |
Chandler Carruth | 9a4c9e5 | 2014-03-06 00:46:21 +0000 | [diff] [blame] | 25 | #include "llvm/IR/DebugInfo.h" |
Chandler Carruth | 9205140 | 2014-03-05 10:30:38 +0000 | [diff] [blame] | 26 | #include "llvm/IR/DebugLoc.h" |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 27 | #include "llvm/MC/MCStreamer.h" |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 28 | #include "llvm/Target/TargetLoweringObjectFile.h" |
| 29 | |
| 30 | namespace llvm { |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 31 | |
Mehdi Amini | b550cb1 | 2016-04-18 09:17:29 +0000 | [diff] [blame] | 32 | class StringRef; |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 33 | class LexicalScope; |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 34 | struct ClassInfo; |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 35 | |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 36 | /// \brief Collects and handles line tables information in a CodeView format. |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 37 | class LLVM_LIBRARY_VISIBILITY CodeViewDebug : public DebugHandlerBase { |
Reid Kleckner | dac21b4 | 2016-02-03 21:15:48 +0000 | [diff] [blame] | 38 | MCStreamer &OS; |
Zachary Turner | c6d54da | 2016-09-09 17:46:17 +0000 | [diff] [blame] | 39 | llvm::BumpPtrAllocator Allocator; |
Reid Kleckner | 2280f93 | 2016-05-23 20:23:46 +0000 | [diff] [blame] | 40 | codeview::MemoryTypeTableBuilder TypeTable; |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 41 | |
Reid Kleckner | 876330d | 2016-02-12 21:48:30 +0000 | [diff] [blame] | 42 | /// Represents the most general definition range. |
| 43 | struct LocalVarDefRange { |
| 44 | /// Indicates that variable data is stored in memory relative to the |
| 45 | /// specified register. |
| 46 | int InMemory : 1; |
| 47 | |
| 48 | /// Offset of variable data in memory. |
| 49 | int DataOffset : 31; |
| 50 | |
| 51 | /// Offset of the data into the user level struct. If zero, no splitting |
| 52 | /// occurred. |
| 53 | uint16_t StructOffset; |
| 54 | |
| 55 | /// Register containing the data or the register base of the memory |
| 56 | /// location containing the data. |
| 57 | uint16_t CVRegister; |
| 58 | |
| 59 | /// Compares all location fields. This includes all fields except the label |
| 60 | /// ranges. |
| 61 | bool isDifferentLocation(LocalVarDefRange &O) { |
| 62 | return InMemory != O.InMemory || DataOffset != O.DataOffset || |
| 63 | StructOffset != O.StructOffset || CVRegister != O.CVRegister; |
| 64 | } |
| 65 | |
| 66 | SmallVector<std::pair<const MCSymbol *, const MCSymbol *>, 1> Ranges; |
| 67 | }; |
| 68 | |
| 69 | static LocalVarDefRange createDefRangeMem(uint16_t CVRegister, int Offset); |
| 70 | static LocalVarDefRange createDefRangeReg(uint16_t CVRegister); |
| 71 | |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 72 | /// Similar to DbgVariable in DwarfDebug, but not dwarf-specific. |
| 73 | struct LocalVariable { |
| 74 | const DILocalVariable *DIVar = nullptr; |
Reid Kleckner | 876330d | 2016-02-12 21:48:30 +0000 | [diff] [blame] | 75 | SmallVector<LocalVarDefRange, 1> DefRanges; |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 76 | }; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 77 | |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 78 | struct InlineSite { |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 79 | SmallVector<LocalVariable, 1> InlinedLocals; |
| 80 | SmallVector<const DILocation *, 1> ChildSites; |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 81 | const DISubprogram *Inlinee = nullptr; |
Reid Kleckner | c29b4f0 | 2016-07-14 23:47:15 +0000 | [diff] [blame] | 82 | |
| 83 | /// The ID of the inline site or function used with .cv_loc. Not a type |
| 84 | /// index. |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 85 | unsigned SiteFuncId = 0; |
| 86 | }; |
| 87 | |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 88 | // For each function, store a vector of labels to its instructions, as well as |
| 89 | // to the end of the function. |
| 90 | struct FunctionInfo { |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 91 | /// Map from inlined call site to inlined instructions and child inlined |
| 92 | /// call sites. Listed in program order. |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 93 | std::unordered_map<const DILocation *, InlineSite> InlineSites; |
| 94 | |
| 95 | /// Ordered list of top-level inlined call sites. |
| 96 | SmallVector<const DILocation *, 1> ChildSites; |
| 97 | |
| 98 | SmallVector<LocalVariable, 1> Locals; |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 99 | |
Reid Kleckner | 9533af4 | 2016-01-16 00:09:09 +0000 | [diff] [blame] | 100 | DebugLoc LastLoc; |
Reid Kleckner | 1fcd610 | 2016-02-02 17:41:18 +0000 | [diff] [blame] | 101 | const MCSymbol *Begin = nullptr; |
| 102 | const MCSymbol *End = nullptr; |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 103 | unsigned FuncId = 0; |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 104 | unsigned LastFileId = 0; |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 105 | bool HaveLineInfo = false; |
Reid Kleckner | 9533af4 | 2016-01-16 00:09:09 +0000 | [diff] [blame] | 106 | }; |
| 107 | FunctionInfo *CurFn; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 108 | |
Reid Kleckner | 5d122f8 | 2016-05-25 23:16:12 +0000 | [diff] [blame] | 109 | /// The set of comdat .debug$S sections that we've seen so far. Each section |
| 110 | /// must start with a magic version number that must only be emitted once. |
| 111 | /// This set tracks which sections we've already opened. |
| 112 | DenseSet<MCSectionCOFF *> ComdatDebugSections; |
| 113 | |
| 114 | /// Switch to the appropriate .debug$S section for GVSym. If GVSym, the symbol |
| 115 | /// of an emitted global value, is in a comdat COFF section, this will switch |
| 116 | /// to a new .debug$S section in that comdat. This method ensures that the |
| 117 | /// section starts with the magic version number on first use. If GVSym is |
| 118 | /// null, uses the main .debug$S section. |
| 119 | void switchToDebugSectionForSymbol(const MCSymbol *GVSym); |
| 120 | |
Reid Kleckner | fbd7787 | 2016-03-18 18:54:32 +0000 | [diff] [blame] | 121 | /// The next available function index for use with our .cv_* directives. Not |
| 122 | /// to be confused with type indices for LF_FUNC_ID records. |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 123 | unsigned NextFuncId = 0; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 124 | |
Reid Kleckner | 876330d | 2016-02-12 21:48:30 +0000 | [diff] [blame] | 125 | InlineSite &getInlineSite(const DILocation *InlinedAt, |
| 126 | const DISubprogram *Inlinee); |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 127 | |
David Majnemer | 75c3ebf | 2016-06-02 17:13:53 +0000 | [diff] [blame] | 128 | codeview::TypeIndex getFuncIdForSubprogram(const DISubprogram *SP); |
Reid Kleckner | 2280f93 | 2016-05-23 20:23:46 +0000 | [diff] [blame] | 129 | |
Reid Kleckner | 1fcd610 | 2016-02-02 17:41:18 +0000 | [diff] [blame] | 130 | static void collectInlineSiteChildren(SmallVectorImpl<unsigned> &Children, |
| 131 | const FunctionInfo &FI, |
| 132 | const InlineSite &Site); |
| 133 | |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 134 | /// Remember some debug info about each function. Keep it in a stable order to |
| 135 | /// emit at the end of the TU. |
| 136 | MapVector<const Function *, FunctionInfo> FnDebugInfo; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 137 | |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 138 | /// Map from DIFile to .cv_file id. |
| 139 | DenseMap<const DIFile *, unsigned> FileIdMap; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 140 | |
Reid Kleckner | fbd7787 | 2016-03-18 18:54:32 +0000 | [diff] [blame] | 141 | /// All inlined subprograms in the order they should be emitted. |
Reid Kleckner | 2280f93 | 2016-05-23 20:23:46 +0000 | [diff] [blame] | 142 | SmallSetVector<const DISubprogram *, 4> InlinedSubprograms; |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 143 | |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 144 | /// Map from a pair of DI metadata nodes and its DI type (or scope) that can |
| 145 | /// be nullptr, to CodeView type indices. Primarily indexed by |
| 146 | /// {DIType*, DIType*} and {DISubprogram*, DIType*}. |
| 147 | /// |
| 148 | /// The second entry in the key is needed for methods as DISubroutineType |
| 149 | /// representing static method type are shared with non-method function type. |
| 150 | DenseMap<std::pair<const DINode *, const DIType *>, codeview::TypeIndex> |
| 151 | TypeIndices; |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 152 | |
Reid Kleckner | a8d5740 | 2016-06-03 15:58:20 +0000 | [diff] [blame] | 153 | /// Map from DICompositeType* to complete type index. Non-record types are |
| 154 | /// always looked up in the normal TypeIndices map. |
| 155 | DenseMap<const DICompositeType *, codeview::TypeIndex> CompleteTypeIndices; |
| 156 | |
Reid Kleckner | 643dd83 | 2016-06-22 17:15:28 +0000 | [diff] [blame] | 157 | /// Complete record types to emit after all active type lowerings are |
| 158 | /// finished. |
| 159 | SmallVector<const DICompositeType *, 4> DeferredCompleteTypes; |
| 160 | |
| 161 | /// Number of type lowering frames active on the stack. |
| 162 | unsigned TypeEmissionLevel = 0; |
| 163 | |
Reid Kleckner | 9f7f3e1 | 2016-06-24 16:24:24 +0000 | [diff] [blame] | 164 | codeview::TypeIndex VBPType; |
| 165 | |
David Majnemer | 3128b10 | 2016-06-15 18:00:01 +0000 | [diff] [blame] | 166 | const DISubprogram *CurrentSubprogram = nullptr; |
| 167 | |
| 168 | // The UDTs we have seen while processing types; each entry is a pair of type |
| 169 | // index and type name. |
| 170 | std::vector<std::pair<std::string, codeview::TypeIndex>> LocalUDTs, |
| 171 | GlobalUDTs; |
| 172 | |
Reid Kleckner | 9533af4 | 2016-01-16 00:09:09 +0000 | [diff] [blame] | 173 | typedef std::map<const DIFile *, std::string> FileToFilepathMapTy; |
| 174 | FileToFilepathMapTy FileToFilepathMap; |
| 175 | StringRef getFullFilepath(const DIFile *S); |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 176 | |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 177 | unsigned maybeRecordFile(const DIFile *F); |
| 178 | |
Benjamin Kramer | bdc4956 | 2016-06-12 15:39:02 +0000 | [diff] [blame] | 179 | void maybeRecordLocation(const DebugLoc &DL, const MachineFunction *MF); |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 180 | |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 181 | void clear(); |
David Majnemer | 3128b10 | 2016-06-15 18:00:01 +0000 | [diff] [blame] | 182 | |
| 183 | void setCurrentSubprogram(const DISubprogram *SP) { |
| 184 | CurrentSubprogram = SP; |
| 185 | LocalUDTs.clear(); |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 186 | } |
| 187 | |
Reid Kleckner | 5d122f8 | 2016-05-25 23:16:12 +0000 | [diff] [blame] | 188 | /// Emit the magic version number at the start of a CodeView type or symbol |
| 189 | /// section. Appears at the front of every .debug$S or .debug$T section. |
| 190 | void emitCodeViewMagicVersion(); |
| 191 | |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 192 | void emitTypeInformation(); |
| 193 | |
Adrian McCarthy | c64acfd | 2016-09-20 17:20:51 +0000 | [diff] [blame^] | 194 | void emitCompilerInformation(); |
| 195 | |
Reid Kleckner | 5d122f8 | 2016-05-25 23:16:12 +0000 | [diff] [blame] | 196 | void emitInlineeLinesSubsection(); |
Reid Kleckner | 1fcd610 | 2016-02-02 17:41:18 +0000 | [diff] [blame] | 197 | |
Reid Kleckner | 2214ed8 | 2016-01-29 00:49:42 +0000 | [diff] [blame] | 198 | void emitDebugInfoForFunction(const Function *GV, FunctionInfo &FI); |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 199 | |
Reid Kleckner | 6f3406d | 2016-06-07 00:02:03 +0000 | [diff] [blame] | 200 | void emitDebugInfoForGlobals(); |
| 201 | |
Hans Wennborg | b510b45 | 2016-06-23 16:33:53 +0000 | [diff] [blame] | 202 | void emitDebugInfoForRetainedTypes(); |
| 203 | |
David Majnemer | 3128b10 | 2016-06-15 18:00:01 +0000 | [diff] [blame] | 204 | void emitDebugInfoForUDTs( |
| 205 | ArrayRef<std::pair<std::string, codeview::TypeIndex>> UDTs); |
| 206 | |
Peter Collingbourne | d4135bb | 2016-09-13 01:12:59 +0000 | [diff] [blame] | 207 | void emitDebugInfoForGlobal(const DIGlobalVariable *DIGV, |
| 208 | const GlobalVariable *GV, MCSymbol *GVSym); |
Reid Kleckner | 6f3406d | 2016-06-07 00:02:03 +0000 | [diff] [blame] | 209 | |
| 210 | /// Opens a subsection of the given kind in a .debug$S codeview section. |
| 211 | /// Returns an end label for use with endCVSubsection when the subsection is |
| 212 | /// finished. |
| 213 | MCSymbol *beginCVSubsection(codeview::ModuleSubstreamKind Kind); |
| 214 | |
| 215 | void endCVSubsection(MCSymbol *EndLabel); |
| 216 | |
Reid Kleckner | f3b9ba4 | 2016-01-29 18:16:43 +0000 | [diff] [blame] | 217 | void emitInlinedCallSite(const FunctionInfo &FI, const DILocation *InlinedAt, |
| 218 | const InlineSite &Site); |
| 219 | |
Reid Kleckner | 876330d | 2016-02-12 21:48:30 +0000 | [diff] [blame] | 220 | typedef DbgValueHistoryMap::InlinedVariable InlinedVariable; |
| 221 | |
| 222 | void collectVariableInfo(const DISubprogram *SP); |
| 223 | |
| 224 | void collectVariableInfoFromMMITable(DenseSet<InlinedVariable> &Processed); |
| 225 | |
| 226 | /// Records information about a local variable in the appropriate scope. In |
| 227 | /// particular, locals from inlined code live inside the inlining site. |
| 228 | void recordLocalVariable(LocalVariable &&Var, const DILocation *Loc); |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 229 | |
Reid Kleckner | 10dd55c | 2016-06-24 17:55:40 +0000 | [diff] [blame] | 230 | /// Emits local variables in the appropriate order. |
| 231 | void emitLocalVariableList(ArrayRef<LocalVariable> Locals); |
| 232 | |
| 233 | /// Emits an S_LOCAL record and its associated defined ranges. |
Reid Kleckner | f9c275f | 2016-02-10 20:55:49 +0000 | [diff] [blame] | 234 | void emitLocalVariable(const LocalVariable &Var); |
| 235 | |
Reid Kleckner | 5acacbb | 2016-06-01 17:05:51 +0000 | [diff] [blame] | 236 | /// Translates the DIType to codeview if necessary and returns a type index |
| 237 | /// for it. |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 238 | codeview::TypeIndex getTypeIndex(DITypeRef TypeRef, |
| 239 | DITypeRef ClassTyRef = DITypeRef()); |
Reid Kleckner | 5acacbb | 2016-06-01 17:05:51 +0000 | [diff] [blame] | 240 | |
Reid Kleckner | 0c5d874 | 2016-06-22 01:32:56 +0000 | [diff] [blame] | 241 | codeview::TypeIndex getMemberFunctionType(const DISubprogram *SP, |
| 242 | const DICompositeType *Class); |
| 243 | |
| 244 | codeview::TypeIndex getScopeIndex(const DIScope *Scope); |
| 245 | |
Reid Kleckner | 9f7f3e1 | 2016-06-24 16:24:24 +0000 | [diff] [blame] | 246 | codeview::TypeIndex getVBPTypeIndex(); |
| 247 | |
Hans Wennborg | 4b63a98 | 2016-06-23 22:57:25 +0000 | [diff] [blame] | 248 | void addToUDTs(const DIType *Ty, codeview::TypeIndex TI); |
| 249 | |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 250 | codeview::TypeIndex lowerType(const DIType *Ty, const DIType *ClassTy); |
David Majnemer | d065e23 | 2016-06-02 06:21:37 +0000 | [diff] [blame] | 251 | codeview::TypeIndex lowerTypeAlias(const DIDerivedType *Ty); |
Adrian McCarthy | f3c3c13 | 2016-06-08 18:22:59 +0000 | [diff] [blame] | 252 | codeview::TypeIndex lowerTypeArray(const DICompositeType *Ty); |
Reid Kleckner | 5acacbb | 2016-06-01 17:05:51 +0000 | [diff] [blame] | 253 | codeview::TypeIndex lowerTypeBasic(const DIBasicType *Ty); |
| 254 | codeview::TypeIndex lowerTypePointer(const DIDerivedType *Ty); |
| 255 | codeview::TypeIndex lowerTypeMemberPointer(const DIDerivedType *Ty); |
| 256 | codeview::TypeIndex lowerTypeModifier(const DIDerivedType *Ty); |
David Majnemer | 75c3ebf | 2016-06-02 17:13:53 +0000 | [diff] [blame] | 257 | codeview::TypeIndex lowerTypeFunction(const DISubroutineType *Ty); |
Reid Kleckner | 9dac473 | 2016-08-31 15:59:30 +0000 | [diff] [blame] | 258 | codeview::TypeIndex lowerTypeVFTableShape(const DIDerivedType *Ty); |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 259 | codeview::TypeIndex lowerTypeMemberFunction(const DISubroutineType *Ty, |
Reid Kleckner | 0c5d874 | 2016-06-22 01:32:56 +0000 | [diff] [blame] | 260 | const DIType *ClassTy, |
| 261 | int ThisAdjustment); |
David Majnemer | 979cb88 | 2016-06-16 21:32:16 +0000 | [diff] [blame] | 262 | codeview::TypeIndex lowerTypeEnum(const DICompositeType *Ty); |
Reid Kleckner | a8d5740 | 2016-06-03 15:58:20 +0000 | [diff] [blame] | 263 | codeview::TypeIndex lowerTypeClass(const DICompositeType *Ty); |
| 264 | codeview::TypeIndex lowerTypeUnion(const DICompositeType *Ty); |
| 265 | |
| 266 | /// Symbol records should point to complete types, but type records should |
| 267 | /// always point to incomplete types to avoid cycles in the type graph. Only |
| 268 | /// use this entry point when generating symbol records. The complete and |
| 269 | /// incomplete type indices only differ for record types. All other types use |
| 270 | /// the same index. |
| 271 | codeview::TypeIndex getCompleteTypeIndex(DITypeRef TypeRef); |
| 272 | |
| 273 | codeview::TypeIndex lowerCompleteTypeClass(const DICompositeType *Ty); |
| 274 | codeview::TypeIndex lowerCompleteTypeUnion(const DICompositeType *Ty); |
| 275 | |
Reid Kleckner | 643dd83 | 2016-06-22 17:15:28 +0000 | [diff] [blame] | 276 | struct TypeLoweringScope; |
| 277 | |
| 278 | void emitDeferredCompleteTypes(); |
| 279 | |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 280 | void collectMemberInfo(ClassInfo &Info, const DIDerivedType *DDTy); |
Reid Kleckner | 1ab7eac | 2016-06-22 16:06:42 +0000 | [diff] [blame] | 281 | ClassInfo collectClassInfo(const DICompositeType *Ty); |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 282 | |
Reid Kleckner | a8d5740 | 2016-06-03 15:58:20 +0000 | [diff] [blame] | 283 | /// Common record member lowering functionality for record types, which are |
| 284 | /// structs, classes, and unions. Returns the field list index and the member |
| 285 | /// count. |
Adrian McCarthy | 820ca54 | 2016-07-06 19:49:51 +0000 | [diff] [blame] | 286 | std::tuple<codeview::TypeIndex, codeview::TypeIndex, unsigned, bool> |
Reid Kleckner | a8d5740 | 2016-06-03 15:58:20 +0000 | [diff] [blame] | 287 | lowerRecordFieldList(const DICompositeType *Ty); |
| 288 | |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 289 | /// Inserts {{Node, ClassTy}, TI} into TypeIndices and checks for duplicates. |
Reid Kleckner | 0c5d874 | 2016-06-22 01:32:56 +0000 | [diff] [blame] | 290 | codeview::TypeIndex recordTypeIndexForDINode(const DINode *Node, |
| 291 | codeview::TypeIndex TI, |
| 292 | const DIType *ClassTy = nullptr); |
Amjad Aboud | 76c9eb9 | 2016-06-18 10:25:07 +0000 | [diff] [blame] | 293 | |
| 294 | unsigned getPointerSizeInBytes(); |
Reid Kleckner | 5acacbb | 2016-06-01 17:05:51 +0000 | [diff] [blame] | 295 | |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 296 | public: |
Reid Kleckner | 70f5bc9 | 2016-01-14 19:25:04 +0000 | [diff] [blame] | 297 | CodeViewDebug(AsmPrinter *Asm); |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 298 | |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 299 | void setSymbolSize(const llvm::MCSymbol *, uint64_t) override {} |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 300 | |
| 301 | /// \brief Emit the COFF section that holds the line table information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 302 | void endModule() override; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 303 | |
| 304 | /// \brief Gather pre-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 305 | void beginFunction(const MachineFunction *MF) override; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 306 | |
| 307 | /// \brief Gather post-function debug information. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 308 | void endFunction(const MachineFunction *) override; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 309 | |
| 310 | /// \brief Process beginning of an instruction. |
Craig Topper | 7b883b3 | 2014-03-08 06:31:39 +0000 | [diff] [blame] | 311 | void beginInstruction(const MachineInstr *MI) override; |
Timur Iskhodzhanov | f166f6c | 2014-01-30 01:39:17 +0000 | [diff] [blame] | 312 | }; |
| 313 | } // End of namespace llvm |
| 314 | |
| 315 | #endif |