Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 1 | //===--- DIBuilder.cpp - Debug Information Builder ------------------------===// |
| 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 implements the DIBuilder. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Chandler Carruth | 12664a0 | 2014-03-06 00:22:06 +0000 | [diff] [blame] | 14 | #include "llvm/IR/DIBuilder.h" |
Chandler Carruth | ed0881b | 2012-12-03 16:50:05 +0000 | [diff] [blame] | 15 | #include "llvm/ADT/STLExtras.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 16 | #include "llvm/IR/Constants.h" |
Chandler Carruth | 9a4c9e5 | 2014-03-06 00:46:21 +0000 | [diff] [blame] | 17 | #include "llvm/IR/DebugInfo.h" |
Chandler Carruth | 9fb823b | 2013-01-02 11:36:10 +0000 | [diff] [blame] | 18 | #include "llvm/IR/IntrinsicInst.h" |
| 19 | #include "llvm/IR/Module.h" |
Eric Christopher | 3416419 | 2012-04-03 00:43:49 +0000 | [diff] [blame] | 20 | #include "llvm/Support/Debug.h" |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 21 | #include "llvm/Support/Dwarf.h" |
| 22 | |
| 23 | using namespace llvm; |
| 24 | using namespace llvm::dwarf; |
| 25 | |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 26 | namespace { |
| 27 | class HeaderBuilder { |
Duncan P. N. Exon Smith | aa687a3 | 2015-01-20 05:02:42 +0000 | [diff] [blame] | 28 | /// \brief Whether there are any fields yet. |
| 29 | /// |
| 30 | /// Note that this is not equivalent to \c Chars.empty(), since \a concat() |
| 31 | /// may have been called already with an empty string. |
| 32 | bool IsEmpty; |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 33 | SmallVector<char, 256> Chars; |
| 34 | |
| 35 | public: |
Duncan P. N. Exon Smith | aa687a3 | 2015-01-20 05:02:42 +0000 | [diff] [blame] | 36 | HeaderBuilder() : IsEmpty(true) {} |
| 37 | HeaderBuilder(const HeaderBuilder &X) : IsEmpty(X.IsEmpty), Chars(X.Chars) {} |
| 38 | HeaderBuilder(HeaderBuilder &&X) |
| 39 | : IsEmpty(X.IsEmpty), Chars(std::move(X.Chars)) {} |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 40 | |
| 41 | template <class Twineable> HeaderBuilder &concat(Twineable &&X) { |
Duncan P. N. Exon Smith | aa687a3 | 2015-01-20 05:02:42 +0000 | [diff] [blame] | 42 | if (IsEmpty) |
| 43 | IsEmpty = false; |
| 44 | else |
| 45 | Chars.push_back(0); |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 46 | Twine(X).toVector(Chars); |
| 47 | return *this; |
| 48 | } |
| 49 | |
| 50 | MDString *get(LLVMContext &Context) const { |
| 51 | return MDString::get(Context, StringRef(Chars.begin(), Chars.size())); |
| 52 | } |
| 53 | |
| 54 | static HeaderBuilder get(unsigned Tag) { |
Duncan P. N. Exon Smith | aa687a3 | 2015-01-20 05:02:42 +0000 | [diff] [blame] | 55 | return HeaderBuilder().concat("0x" + Twine::utohexstr(Tag)); |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 56 | } |
| 57 | }; |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 58 | } |
Devang Patel | 63f83cd | 2010-12-07 23:58:00 +0000 | [diff] [blame] | 59 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 60 | DIBuilder::DIBuilder(Module &m, bool AllowUnresolvedNodes) |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 61 | : M(m), VMContext(M.getContext()), TempEnumTypes(nullptr), |
| 62 | TempRetainTypes(nullptr), TempSubprograms(nullptr), TempGVs(nullptr), |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 63 | DeclareFn(nullptr), ValueFn(nullptr), |
| 64 | AllowUnresolvedNodes(AllowUnresolvedNodes) {} |
| 65 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 66 | void DIBuilder::trackIfUnresolved(MDNode *N) { |
Duncan P. N. Exon Smith | 9b1c6d3 | 2015-01-19 19:09:14 +0000 | [diff] [blame] | 67 | if (!N) |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 68 | return; |
Duncan P. N. Exon Smith | 9b1c6d3 | 2015-01-19 19:09:14 +0000 | [diff] [blame] | 69 | if (N->isResolved()) |
| 70 | return; |
| 71 | |
| 72 | assert(AllowUnresolvedNodes && "Cannot handle unresolved nodes"); |
| 73 | UnresolvedNodes.emplace_back(N); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 74 | } |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 75 | |
Devang Patel | 2b8acaf | 2011-08-15 23:00:00 +0000 | [diff] [blame] | 76 | void DIBuilder::finalize() { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 77 | TempEnumTypes->replaceAllUsesWith(MDTuple::get(VMContext, AllEnumTypes)); |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 78 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 79 | SmallVector<Metadata *, 16> RetainValues; |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 80 | // Declarations and definitions of the same type may be retained. Some |
| 81 | // clients RAUW these pairs, leaving duplicates in the retained types |
| 82 | // list. Use a set to remove the duplicates while we transform the |
| 83 | // TrackingVHs back into Values. |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 84 | SmallPtrSet<Metadata *, 16> RetainSet; |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 85 | for (unsigned I = 0, E = AllRetainTypes.size(); I < E; I++) |
David Blaikie | 70573dc | 2014-11-19 07:49:26 +0000 | [diff] [blame] | 86 | if (RetainSet.insert(AllRetainTypes[I]).second) |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 87 | RetainValues.push_back(AllRetainTypes[I]); |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 88 | TempRetainTypes->replaceAllUsesWith(MDTuple::get(VMContext, RetainValues)); |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 89 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 90 | MDSubprogramArray SPs = MDTuple::get(VMContext, AllSubprograms); |
Duncan P. N. Exon Smith | 1134473 | 2015-04-07 16:50:39 +0000 | [diff] [blame] | 91 | TempSubprograms->replaceAllUsesWith(SPs.get()); |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 92 | for (auto *SP : SPs) { |
Duncan P. N. Exon Smith | 537b4a8 | 2015-04-14 03:40:37 +0000 | [diff] [blame] | 93 | if (MDTuple *Temp = SP->getVariables().get()) { |
Benjamin Kramer | 6cd780f | 2015-02-17 15:29:18 +0000 | [diff] [blame] | 94 | const auto &PV = PreservedVariables.lookup(SP); |
| 95 | SmallVector<Metadata *, 4> Variables(PV.begin(), PV.end()); |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 96 | DebugNodeArray AV = getOrCreateArray(Variables); |
Duncan P. N. Exon Smith | 457bfc7 | 2015-04-10 18:01:58 +0000 | [diff] [blame] | 97 | TempMDTuple(Temp)->replaceAllUsesWith(AV.get()); |
Eric Christopher | 27deb26 | 2012-04-23 19:00:11 +0000 | [diff] [blame] | 98 | } |
Devang Patel | 59e27c5 | 2011-08-19 23:28:12 +0000 | [diff] [blame] | 99 | } |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 100 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 101 | TempGVs->replaceAllUsesWith(MDTuple::get(VMContext, AllGVs)); |
David Blaikie | f55abea | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 102 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 103 | TempImportedModules->replaceAllUsesWith(MDTuple::get( |
| 104 | VMContext, SmallVector<Metadata *, 16>(AllImportedModules.begin(), |
| 105 | AllImportedModules.end()))); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 106 | |
| 107 | // Now that all temp nodes have been replaced or deleted, resolve remaining |
| 108 | // cycles. |
| 109 | for (const auto &N : UnresolvedNodes) |
Duncan P. N. Exon Smith | 2bc00f4 | 2015-01-19 23:13:14 +0000 | [diff] [blame] | 110 | if (N && !N->isResolved()) |
| 111 | N->resolveCycles(); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 112 | UnresolvedNodes.clear(); |
| 113 | |
| 114 | // Can't handle unresolved nodes anymore. |
| 115 | AllowUnresolvedNodes = false; |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 116 | } |
| 117 | |
Duncan P. N. Exon Smith | 379e375 | 2014-10-01 21:32:15 +0000 | [diff] [blame] | 118 | /// If N is compile unit return NULL otherwise return N. |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 119 | static MDScope *getNonCompileUnitScope(MDScope *N) { |
Duncan P. N. Exon Smith | 3cd2cab | 2015-03-27 00:34:10 +0000 | [diff] [blame] | 120 | if (!N || isa<MDCompileUnit>(N)) |
Craig Topper | c620761 | 2014-04-09 06:08:46 +0000 | [diff] [blame] | 121 | return nullptr; |
Duncan P. N. Exon Smith | 3cd2cab | 2015-03-27 00:34:10 +0000 | [diff] [blame] | 122 | return cast<MDScope>(N); |
Devang Patel | 2b8acaf | 2011-08-15 23:00:00 +0000 | [diff] [blame] | 123 | } |
| 124 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 125 | MDCompileUnit *DIBuilder::createCompileUnit( |
| 126 | unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer, |
| 127 | bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName, |
| 128 | DebugEmissionKind Kind, bool EmitDebugInfo) { |
Eric Christopher | 75d49db | 2014-02-27 01:24:56 +0000 | [diff] [blame] | 129 | |
Bruce Mitchener | 7e575ed | 2015-02-07 06:35:30 +0000 | [diff] [blame] | 130 | assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) || |
Chandler Carruth | 4c0ee74 | 2012-01-10 18:18:52 +0000 | [diff] [blame] | 131 | (Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) && |
| 132 | "Invalid Language tag"); |
| 133 | assert(!Filename.empty() && |
| 134 | "Unable to create compile unit without filename"); |
Devang Patel | eb1bb4e | 2011-08-16 22:09:43 +0000 | [diff] [blame] | 135 | |
Duncan P. N. Exon Smith | b93569d | 2015-02-12 21:52:11 +0000 | [diff] [blame] | 136 | // TODO: Once we make MDCompileUnit distinct, stop using temporaries here |
| 137 | // (just start with operands assigned to nullptr). |
Duncan P. N. Exon Smith | 457bfc7 | 2015-04-10 18:01:58 +0000 | [diff] [blame] | 138 | TempEnumTypes = MDTuple::getTemporary(VMContext, None); |
| 139 | TempRetainTypes = MDTuple::getTemporary(VMContext, None); |
| 140 | TempSubprograms = MDTuple::getTemporary(VMContext, None); |
| 141 | TempGVs = MDTuple::getTemporary(VMContext, None); |
| 142 | TempImportedModules = MDTuple::getTemporary(VMContext, None); |
David Blaikie | f55abea | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 143 | |
Duncan P. N. Exon Smith | b93569d | 2015-02-12 21:52:11 +0000 | [diff] [blame] | 144 | // TODO: Switch to getDistinct(). We never want to merge compile units based |
| 145 | // on contents. |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 146 | MDCompileUnit *CUNode = MDCompileUnit::get( |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 147 | VMContext, Lang, MDFile::get(VMContext, Filename, Directory), Producer, |
Duncan P. N. Exon Smith | 457bfc7 | 2015-04-10 18:01:58 +0000 | [diff] [blame] | 148 | isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(), |
| 149 | TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(), |
| 150 | TempImportedModules.get()); |
Devang Patel | 09fa69e | 2011-05-03 16:18:28 +0000 | [diff] [blame] | 151 | |
| 152 | // Create a named metadata so that it is easier to find cu in a module. |
Diego Novillo | 56653fd | 2014-06-24 17:02:03 +0000 | [diff] [blame] | 153 | // Note that we only generate this when the caller wants to actually |
| 154 | // emit debug information. When we are only interested in tracking |
| 155 | // source line locations throughout the backend, we prevent codegen from |
| 156 | // emitting debug info in the final output by not generating llvm.dbg.cu. |
| 157 | if (EmitDebugInfo) { |
| 158 | NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu"); |
| 159 | NMD->addOperand(CUNode); |
| 160 | } |
Eric Christopher | 03b3e11 | 2013-07-19 00:51:47 +0000 | [diff] [blame] | 161 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 162 | trackIfUnresolved(CUNode); |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 163 | return CUNode; |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 164 | } |
| 165 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 166 | static MDImportedEntity* |
| 167 | createImportedModule(LLVMContext &C, dwarf::Tag Tag, MDScope* Context, |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 168 | Metadata *NS, unsigned Line, StringRef Name, |
| 169 | SmallVectorImpl<TrackingMDNodeRef> &AllImportedModules) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 170 | auto *M = |
Duncan P. N. Exon Smith | d5e6a15 | 2015-04-07 04:07:31 +0000 | [diff] [blame] | 171 | MDImportedEntity::get(C, Tag, Context, DebugNodeRef(NS), Line, Name); |
Duncan P. N. Exon Smith | de8e427 | 2015-04-14 01:46:44 +0000 | [diff] [blame] | 172 | AllImportedModules.emplace_back(M); |
David Blaikie | 1fd4365 | 2013-05-07 21:35:53 +0000 | [diff] [blame] | 173 | return M; |
| 174 | } |
| 175 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 176 | MDImportedEntity* DIBuilder::createImportedModule(MDScope* Context, |
| 177 | MDNamespace* NS, |
David Blaikie | 2a40c14 | 2014-04-06 06:29:01 +0000 | [diff] [blame] | 178 | unsigned Line) { |
| 179 | return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module, |
| 180 | Context, NS, Line, StringRef(), AllImportedModules); |
David Blaikie | e63d5d1 | 2013-05-20 22:50:35 +0000 | [diff] [blame] | 181 | } |
| 182 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 183 | MDImportedEntity* DIBuilder::createImportedModule(MDScope* Context, |
| 184 | MDImportedEntity* NS, |
David Blaikie | 2a40c14 | 2014-04-06 06:29:01 +0000 | [diff] [blame] | 185 | unsigned Line) { |
| 186 | return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_module, |
| 187 | Context, NS, Line, StringRef(), AllImportedModules); |
David Blaikie | e63d5d1 | 2013-05-20 22:50:35 +0000 | [diff] [blame] | 188 | } |
| 189 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 190 | MDImportedEntity *DIBuilder::createImportedDeclaration(MDScope *Context, |
| 191 | DebugNode *Decl, |
| 192 | unsigned Line, |
| 193 | StringRef Name) { |
Frederic Riss | 4aa51ae | 2014-11-06 17:46:55 +0000 | [diff] [blame] | 194 | // Make sure to use the unique identifier based metadata reference for |
| 195 | // types that have one. |
David Blaikie | 2a40c14 | 2014-04-06 06:29:01 +0000 | [diff] [blame] | 196 | return ::createImportedModule(VMContext, dwarf::DW_TAG_imported_declaration, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 197 | Context, DebugNodeRef::get(Decl), Line, Name, |
| 198 | AllImportedModules); |
David Blaikie | f55abea | 2013-04-22 06:12:31 +0000 | [diff] [blame] | 199 | } |
| 200 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 201 | MDFile* DIBuilder::createFile(StringRef Filename, StringRef Directory) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 202 | return MDFile::get(VMContext, Filename, Directory); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 203 | } |
| 204 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 205 | MDEnumerator *DIBuilder::createEnumerator(StringRef Name, int64_t Val) { |
Devang Patel | 1ad1abe | 2011-09-12 18:26:08 +0000 | [diff] [blame] | 206 | assert(!Name.empty() && "Unable to create enumerator without name"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 207 | return MDEnumerator::get(VMContext, Val, Name); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 208 | } |
| 209 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 210 | MDBasicType *DIBuilder::createUnspecifiedType(StringRef Name) { |
Devang Patel | 04d6d47 | 2011-09-14 23:13:28 +0000 | [diff] [blame] | 211 | assert(!Name.empty() && "Unable to create type without name"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 212 | return MDBasicType::get(VMContext, dwarf::DW_TAG_unspecified_type, Name); |
Devang Patel | 04d6d47 | 2011-09-14 23:13:28 +0000 | [diff] [blame] | 213 | } |
| 214 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 215 | MDBasicType *DIBuilder::createNullPtrType() { |
Peter Collingbourne | a4a47cb | 2013-06-27 22:50:59 +0000 | [diff] [blame] | 216 | return createUnspecifiedType("decltype(nullptr)"); |
| 217 | } |
| 218 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 219 | MDBasicType *DIBuilder::createBasicType(StringRef Name, uint64_t SizeInBits, |
| 220 | uint64_t AlignInBits, |
| 221 | unsigned Encoding) { |
Devang Patel | 1ad1abe | 2011-09-12 18:26:08 +0000 | [diff] [blame] | 222 | assert(!Name.empty() && "Unable to create type without name"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 223 | return MDBasicType::get(VMContext, dwarf::DW_TAG_base_type, Name, SizeInBits, |
| 224 | AlignInBits, Encoding); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 225 | } |
| 226 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 227 | MDDerivedType *DIBuilder::createQualifiedType(unsigned Tag, MDType *FromTy) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 228 | return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 229 | MDTypeRef::get(FromTy), 0, 0, 0, 0); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 230 | } |
| 231 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 232 | MDDerivedType *DIBuilder::createPointerType(MDType *PointeeTy, |
| 233 | uint64_t SizeInBits, |
| 234 | uint64_t AlignInBits, |
| 235 | StringRef Name) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 236 | // FIXME: Why is there a name here? |
| 237 | return MDDerivedType::get(VMContext, dwarf::DW_TAG_pointer_type, Name, |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 238 | nullptr, 0, nullptr, MDTypeRef::get(PointeeTy), |
| 239 | SizeInBits, AlignInBits, 0, 0); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 240 | } |
| 241 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 242 | MDDerivedType *DIBuilder::createMemberPointerType(MDType *PointeeTy, |
| 243 | MDType *Base, |
| 244 | uint64_t SizeInBits, |
| 245 | uint64_t AlignInBits) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 246 | return MDDerivedType::get(VMContext, dwarf::DW_TAG_ptr_to_member_type, "", |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 247 | nullptr, 0, nullptr, MDTypeRef::get(PointeeTy), |
| 248 | SizeInBits, AlignInBits, 0, 0, MDTypeRef::get(Base)); |
David Blaikie | 5d3249b | 2013-01-07 05:51:15 +0000 | [diff] [blame] | 249 | } |
| 250 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 251 | MDDerivedType *DIBuilder::createReferenceType(unsigned Tag, MDType *RTy) { |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 252 | assert(RTy && "Unable to create reference type"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 253 | return MDDerivedType::get(VMContext, Tag, "", nullptr, 0, nullptr, |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 254 | MDTypeRef::get(RTy), 0, 0, 0, 0); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 255 | } |
| 256 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 257 | MDDerivedType *DIBuilder::createTypedef(MDType *Ty, StringRef Name, |
| 258 | MDFile *File, unsigned LineNo, |
| 259 | MDScope *Context) { |
| 260 | return MDDerivedType::get(VMContext, dwarf::DW_TAG_typedef, Name, File, |
| 261 | LineNo, |
| 262 | MDScopeRef::get(getNonCompileUnitScope(Context)), |
| 263 | MDTypeRef::get(Ty), 0, 0, 0, 0); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 264 | } |
| 265 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 266 | MDDerivedType *DIBuilder::createFriend(MDType *Ty, MDType *FriendTy) { |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 267 | assert(Ty && "Invalid type!"); |
| 268 | assert(FriendTy && "Invalid friend type!"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 269 | return MDDerivedType::get(VMContext, dwarf::DW_TAG_friend, "", nullptr, 0, |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 270 | MDTypeRef::get(Ty), MDTypeRef::get(FriendTy), 0, 0, |
| 271 | 0, 0); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 272 | } |
| 273 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 274 | MDDerivedType *DIBuilder::createInheritance(MDType *Ty, MDType *BaseTy, |
| 275 | uint64_t BaseOffset, |
| 276 | unsigned Flags) { |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 277 | assert(Ty && "Unable to create inheritance"); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 278 | return MDDerivedType::get(VMContext, dwarf::DW_TAG_inheritance, "", nullptr, |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 279 | 0, MDTypeRef::get(Ty), MDTypeRef::get(BaseTy), 0, 0, |
| 280 | BaseOffset, Flags); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 281 | } |
| 282 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 283 | MDDerivedType *DIBuilder::createMemberType(MDScope *Scope, StringRef Name, |
| 284 | MDFile *File, unsigned LineNumber, |
| 285 | uint64_t SizeInBits, |
| 286 | uint64_t AlignInBits, |
| 287 | uint64_t OffsetInBits, |
| 288 | unsigned Flags, MDType *Ty) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 289 | return MDDerivedType::get( |
| 290 | VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 291 | MDScopeRef::get(getNonCompileUnitScope(Scope)), MDTypeRef::get(Ty), |
| 292 | SizeInBits, AlignInBits, OffsetInBits, Flags); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 293 | } |
| 294 | |
Duncan P. N. Exon Smith | 3cd2cab | 2015-03-27 00:34:10 +0000 | [diff] [blame] | 295 | static ConstantAsMetadata *getConstantOrNull(Constant *C) { |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 296 | if (C) |
| 297 | return ConstantAsMetadata::get(C); |
| 298 | return nullptr; |
| 299 | } |
| 300 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 301 | MDDerivedType *DIBuilder::createStaticMemberType(MDScope *Scope, StringRef Name, |
| 302 | MDFile *File, |
| 303 | unsigned LineNumber, |
| 304 | MDType *Ty, unsigned Flags, |
| 305 | llvm::Constant *Val) { |
Duncan P. N. Exon Smith | f15c6f8 | 2015-04-16 01:53:33 +0000 | [diff] [blame] | 306 | Flags |= DebugNode::FlagStaticMember; |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 307 | return MDDerivedType::get( |
| 308 | VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 309 | MDScopeRef::get(getNonCompileUnitScope(Scope)), MDTypeRef::get(Ty), 0, 0, |
| 310 | 0, Flags, getConstantOrNull(Val)); |
Eric Christopher | 4d23a4a | 2013-01-16 01:22:23 +0000 | [diff] [blame] | 311 | } |
| 312 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 313 | MDDerivedType *DIBuilder::createObjCIVar(StringRef Name, MDFile *File, |
| 314 | unsigned LineNumber, |
| 315 | uint64_t SizeInBits, |
| 316 | uint64_t AlignInBits, |
| 317 | uint64_t OffsetInBits, unsigned Flags, |
| 318 | MDType *Ty, MDNode *PropertyNode) { |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 319 | return MDDerivedType::get( |
| 320 | VMContext, dwarf::DW_TAG_member, Name, File, LineNumber, |
| 321 | MDScopeRef::get(getNonCompileUnitScope(File)), MDTypeRef::get(Ty), |
| 322 | SizeInBits, AlignInBits, OffsetInBits, Flags, PropertyNode); |
Devang Patel | 4488217 | 2012-02-06 17:49:43 +0000 | [diff] [blame] | 323 | } |
| 324 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 325 | MDObjCProperty * |
| 326 | DIBuilder::createObjCProperty(StringRef Name, MDFile *File, unsigned LineNumber, |
Eric Christopher | 98f9c23 | 2013-10-15 23:31:31 +0000 | [diff] [blame] | 327 | StringRef GetterName, StringRef SetterName, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 328 | unsigned PropertyAttributes, MDType *Ty) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 329 | return MDObjCProperty::get(VMContext, Name, File, LineNumber, GetterName, |
| 330 | SetterName, PropertyAttributes, Ty); |
Devang Patel | cc48159 | 2012-02-04 00:59:25 +0000 | [diff] [blame] | 331 | } |
| 332 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 333 | MDTemplateTypeParameter * |
| 334 | DIBuilder::createTemplateTypeParameter(MDScope *Context, StringRef Name, |
| 335 | MDType *Ty) { |
Duncan P. N. Exon Smith | b273d06 | 2015-04-16 01:37:00 +0000 | [diff] [blame] | 336 | assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit"); |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 337 | return MDTemplateTypeParameter::get(VMContext, Name, MDTypeRef::get(Ty)); |
Devang Patel | 3a9e65e | 2011-02-02 21:38:25 +0000 | [diff] [blame] | 338 | } |
| 339 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 340 | static MDTemplateValueParameter * |
Duncan P. N. Exon Smith | b4aa16f | 2015-02-13 03:35:29 +0000 | [diff] [blame] | 341 | createTemplateValueParameterHelper(LLVMContext &VMContext, unsigned Tag, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 342 | MDScope *Context, StringRef Name, MDType *Ty, |
| 343 | Metadata *MD) { |
Duncan P. N. Exon Smith | b273d06 | 2015-04-16 01:37:00 +0000 | [diff] [blame] | 344 | assert((!Context || isa<MDCompileUnit>(Context)) && "Expected compile unit"); |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 345 | return MDTemplateValueParameter::get(VMContext, Tag, Name, MDTypeRef::get(Ty), |
| 346 | MD); |
Devang Patel | be933b4 | 2011-02-02 22:35:53 +0000 | [diff] [blame] | 347 | } |
| 348 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 349 | MDTemplateValueParameter * |
| 350 | DIBuilder::createTemplateValueParameter(MDScope *Context, StringRef Name, |
| 351 | MDType *Ty, Constant *Val) { |
Duncan P. N. Exon Smith | 774951f | 2014-11-15 00:05:04 +0000 | [diff] [blame] | 352 | return createTemplateValueParameterHelper( |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 353 | VMContext, dwarf::DW_TAG_template_value_parameter, Context, Name, Ty, |
Duncan P. N. Exon Smith | b4aa16f | 2015-02-13 03:35:29 +0000 | [diff] [blame] | 354 | getConstantOrNull(Val)); |
David Blaikie | 2b38023 | 2013-06-22 18:59:11 +0000 | [diff] [blame] | 355 | } |
| 356 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 357 | MDTemplateValueParameter * |
| 358 | DIBuilder::createTemplateTemplateParameter(MDScope *Context, StringRef Name, |
| 359 | MDType *Ty, StringRef Val) { |
Duncan P. N. Exon Smith | 774951f | 2014-11-15 00:05:04 +0000 | [diff] [blame] | 360 | return createTemplateValueParameterHelper( |
| 361 | VMContext, dwarf::DW_TAG_GNU_template_template_param, Context, Name, Ty, |
Duncan P. N. Exon Smith | b4aa16f | 2015-02-13 03:35:29 +0000 | [diff] [blame] | 362 | MDString::get(VMContext, Val)); |
David Blaikie | 2b38023 | 2013-06-22 18:59:11 +0000 | [diff] [blame] | 363 | } |
| 364 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 365 | MDTemplateValueParameter * |
| 366 | DIBuilder::createTemplateParameterPack(MDScope *Context, StringRef Name, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 367 | MDType *Ty, DebugNodeArray Val) { |
Duncan P. N. Exon Smith | 774951f | 2014-11-15 00:05:04 +0000 | [diff] [blame] | 368 | return createTemplateValueParameterHelper( |
| 369 | VMContext, dwarf::DW_TAG_GNU_template_parameter_pack, Context, Name, Ty, |
Duncan P. N. Exon Smith | 1134473 | 2015-04-07 16:50:39 +0000 | [diff] [blame] | 370 | Val.get()); |
David Blaikie | 2b38023 | 2013-06-22 18:59:11 +0000 | [diff] [blame] | 371 | } |
| 372 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 373 | MDCompositeType *DIBuilder::createClassType( |
| 374 | MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber, |
| 375 | uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 376 | unsigned Flags, MDType *DerivedFrom, DebugNodeArray Elements, |
| 377 | MDType *VTableHolder, MDNode *TemplateParams, StringRef UniqueIdentifier) { |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 378 | assert((!Context || isa<MDScope>(Context)) && |
David Blaikie | 085abe3 | 2013-03-11 23:21:19 +0000 | [diff] [blame] | 379 | "createClassType should be called with a valid Context"); |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 380 | |
| 381 | auto *R = MDCompositeType::get( |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 382 | VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 383 | MDScopeRef::get(getNonCompileUnitScope(Context)), |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 384 | MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, OffsetInBits, Flags, |
| 385 | Elements, 0, MDTypeRef::get(VTableHolder), |
| 386 | cast_or_null<MDTuple>(TemplateParams), UniqueIdentifier); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 387 | if (!UniqueIdentifier.empty()) |
| 388 | retainType(R); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 389 | trackIfUnresolved(R); |
David Blaikie | 085abe3 | 2013-03-11 23:21:19 +0000 | [diff] [blame] | 390 | return R; |
Eric Christopher | 1742669 | 2012-07-06 02:35:57 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 393 | MDCompositeType *DIBuilder::createStructType( |
| 394 | MDScope *Context, StringRef Name, MDFile *File, unsigned LineNumber, |
| 395 | uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 396 | MDType *DerivedFrom, DebugNodeArray Elements, unsigned RunTimeLang, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 397 | MDType *VTableHolder, StringRef UniqueIdentifier) { |
| 398 | auto *R = MDCompositeType::get( |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 399 | VMContext, dwarf::DW_TAG_structure_type, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 400 | MDScopeRef::get(getNonCompileUnitScope(Context)), |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 401 | MDTypeRef::get(DerivedFrom), SizeInBits, AlignInBits, 0, Flags, Elements, |
| 402 | RunTimeLang, MDTypeRef::get(VTableHolder), nullptr, UniqueIdentifier); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 403 | if (!UniqueIdentifier.empty()) |
| 404 | retainType(R); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 405 | trackIfUnresolved(R); |
David Blaikie | 085abe3 | 2013-03-11 23:21:19 +0000 | [diff] [blame] | 406 | return R; |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 407 | } |
| 408 | |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 409 | MDCompositeType *DIBuilder::createUnionType( |
| 410 | MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, |
| 411 | uint64_t SizeInBits, uint64_t AlignInBits, unsigned Flags, |
| 412 | DebugNodeArray Elements, unsigned RunTimeLang, StringRef UniqueIdentifier) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 413 | auto *R = MDCompositeType::get( |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 414 | VMContext, dwarf::DW_TAG_union_type, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 415 | MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits, |
| 416 | AlignInBits, 0, Flags, Elements, RunTimeLang, nullptr, nullptr, |
| 417 | UniqueIdentifier); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 418 | if (!UniqueIdentifier.empty()) |
| 419 | retainType(R); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 420 | trackIfUnresolved(R); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 421 | return R; |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 422 | } |
| 423 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 424 | MDSubroutineType *DIBuilder::createSubroutineType(MDFile *File, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 425 | MDTypeRefArray ParameterTypes, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 426 | unsigned Flags) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 427 | return MDSubroutineType::get(VMContext, Flags, ParameterTypes); |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 428 | } |
| 429 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 430 | MDCompositeType *DIBuilder::createEnumerationType( |
| 431 | MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNumber, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 432 | uint64_t SizeInBits, uint64_t AlignInBits, DebugNodeArray Elements, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 433 | MDType *UnderlyingType, StringRef UniqueIdentifier) { |
| 434 | auto *CTy = MDCompositeType::get( |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 435 | VMContext, dwarf::DW_TAG_enumeration_type, Name, File, LineNumber, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 436 | MDScopeRef::get(getNonCompileUnitScope(Scope)), |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 437 | MDTypeRef::get(UnderlyingType), SizeInBits, AlignInBits, 0, 0, Elements, |
| 438 | 0, nullptr, nullptr, UniqueIdentifier); |
David Blaikie | 4f6bf27a | 2013-11-18 23:33:32 +0000 | [diff] [blame] | 439 | AllEnumTypes.push_back(CTy); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 440 | if (!UniqueIdentifier.empty()) |
David Blaikie | 4f6bf27a | 2013-11-18 23:33:32 +0000 | [diff] [blame] | 441 | retainType(CTy); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 442 | trackIfUnresolved(CTy); |
David Blaikie | 4f6bf27a | 2013-11-18 23:33:32 +0000 | [diff] [blame] | 443 | return CTy; |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 446 | MDCompositeType *DIBuilder::createArrayType(uint64_t Size, uint64_t AlignInBits, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 447 | MDType *Ty, |
| 448 | DebugNodeArray Subscripts) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 449 | auto *R = MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 450 | nullptr, 0, nullptr, MDTypeRef::get(Ty), Size, |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 451 | AlignInBits, 0, 0, Subscripts, 0, nullptr); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 452 | trackIfUnresolved(R); |
| 453 | return R; |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 454 | } |
| 455 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 456 | MDCompositeType *DIBuilder::createVectorType(uint64_t Size, |
| 457 | uint64_t AlignInBits, MDType *Ty, |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 458 | DebugNodeArray Subscripts) { |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 459 | auto *R = |
| 460 | MDCompositeType::get(VMContext, dwarf::DW_TAG_array_type, "", nullptr, 0, |
| 461 | nullptr, MDTypeRef::get(Ty), Size, AlignInBits, 0, |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 462 | DebugNode::FlagVector, Subscripts, 0, nullptr); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 463 | trackIfUnresolved(R); |
| 464 | return R; |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 465 | } |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 466 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 467 | static MDType *createTypeWithFlags(LLVMContext &Context, MDType *Ty, |
| 468 | unsigned FlagsToSet) { |
| 469 | auto NewTy = Ty->clone(); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 470 | NewTy->setFlags(NewTy->getFlags() | FlagsToSet); |
| 471 | return MDNode::replaceWithUniqued(std::move(NewTy)); |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 472 | } |
| 473 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 474 | MDType *DIBuilder::createArtificialType(MDType *Ty) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 475 | // FIXME: Restrict this to the nodes where it's valid. |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 476 | if (Ty->isArtificial()) |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 477 | return Ty; |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 478 | return createTypeWithFlags(VMContext, Ty, DebugNode::FlagArtificial); |
Devang Patel | 57c5a20 | 2010-11-04 15:01:38 +0000 | [diff] [blame] | 479 | } |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 480 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 481 | MDType *DIBuilder::createObjectPointerType(MDType *Ty) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 482 | // FIXME: Restrict this to the nodes where it's valid. |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 483 | if (Ty->isObjectPointer()) |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 484 | return Ty; |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 485 | unsigned Flags = DebugNode::FlagObjectPointer | DebugNode::FlagArtificial; |
Duncan P. N. Exon Smith | 176b691 | 2014-10-03 20:01:09 +0000 | [diff] [blame] | 486 | return createTypeWithFlags(VMContext, Ty, Flags); |
Eric Christopher | e341776 | 2012-09-12 23:36:19 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 489 | void DIBuilder::retainType(MDType *T) { |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 490 | assert(T && "Expected non-null type"); |
Duncan P. N. Exon Smith | d9ccfb9 | 2015-03-27 23:00:49 +0000 | [diff] [blame] | 491 | AllRetainTypes.emplace_back(T); |
| 492 | } |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 493 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 494 | MDBasicType *DIBuilder::createUnspecifiedParameter() { return nullptr; } |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 495 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 496 | MDCompositeType* |
| 497 | DIBuilder::createForwardDecl(unsigned Tag, StringRef Name, MDScope * Scope, |
| 498 | MDFile* F, unsigned Line, unsigned RuntimeLang, |
Eric Christopher | 98f9c23 | 2013-10-15 23:31:31 +0000 | [diff] [blame] | 499 | uint64_t SizeInBits, uint64_t AlignInBits, |
| 500 | StringRef UniqueIdentifier) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 501 | // FIXME: Define in terms of createReplaceableForwardDecl() by calling |
| 502 | // replaceWithUniqued(). |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 503 | auto *RetTy = MDCompositeType::get( |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 504 | VMContext, Tag, Name, F, Line, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 505 | MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, SizeInBits, |
| 506 | AlignInBits, 0, DebugNode::FlagFwdDecl, nullptr, RuntimeLang, nullptr, |
| 507 | nullptr, UniqueIdentifier); |
David Blaikie | d3f094a | 2014-05-06 03:41:57 +0000 | [diff] [blame] | 508 | if (!UniqueIdentifier.empty()) |
| 509 | retainType(RetTy); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 510 | trackIfUnresolved(RetTy); |
David Blaikie | d3f094a | 2014-05-06 03:41:57 +0000 | [diff] [blame] | 511 | return RetTy; |
| 512 | } |
| 513 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 514 | MDCompositeType* DIBuilder::createReplaceableCompositeType( |
| 515 | unsigned Tag, StringRef Name, MDScope * Scope, MDFile* F, unsigned Line, |
David Blaikie | d3f094a | 2014-05-06 03:41:57 +0000 | [diff] [blame] | 516 | unsigned RuntimeLang, uint64_t SizeInBits, uint64_t AlignInBits, |
Adrian Prantl | 534a81a | 2015-02-11 17:45:05 +0000 | [diff] [blame] | 517 | unsigned Flags, StringRef UniqueIdentifier) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 518 | auto *RetTy = MDCompositeType::getTemporary( |
| 519 | VMContext, Tag, Name, F, Line, |
| 520 | MDScopeRef::get(getNonCompileUnitScope(Scope)), nullptr, |
| 521 | SizeInBits, AlignInBits, 0, Flags, nullptr, RuntimeLang, |
| 522 | nullptr, nullptr, UniqueIdentifier).release(); |
Manman Ren | 0b41040 | 2013-08-29 23:17:54 +0000 | [diff] [blame] | 523 | if (!UniqueIdentifier.empty()) |
| 524 | retainType(RetTy); |
Adrian Prantl | ea7f1c2 | 2015-02-17 19:17:39 +0000 | [diff] [blame] | 525 | trackIfUnresolved(RetTy); |
Manman Ren | d0e67aa | 2013-07-02 18:37:35 +0000 | [diff] [blame] | 526 | return RetTy; |
Eric Christopher | ae56eec | 2012-02-08 00:22:26 +0000 | [diff] [blame] | 527 | } |
| 528 | |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 529 | DebugNodeArray DIBuilder::getOrCreateArray(ArrayRef<Metadata *> Elements) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 530 | return MDTuple::get(VMContext, Elements); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 531 | } |
| 532 | |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 533 | MDTypeRefArray DIBuilder::getOrCreateTypeArray(ArrayRef<Metadata *> Elements) { |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 534 | SmallVector<llvm::Metadata *, 16> Elts; |
Manman Ren | 1a125c9 | 2014-07-28 19:33:20 +0000 | [diff] [blame] | 535 | for (unsigned i = 0, e = Elements.size(); i != e; ++i) { |
| 536 | if (Elements[i] && isa<MDNode>(Elements[i])) |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 537 | Elts.push_back(MDTypeRef::get(cast<MDType>(Elements[i]))); |
Manman Ren | 1a125c9 | 2014-07-28 19:33:20 +0000 | [diff] [blame] | 538 | else |
| 539 | Elts.push_back(Elements[i]); |
| 540 | } |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 541 | return MDTypeRefArray(MDNode::get(VMContext, Elts)); |
Manman Ren | 1a125c9 | 2014-07-28 19:33:20 +0000 | [diff] [blame] | 542 | } |
| 543 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 544 | MDSubrange *DIBuilder::getOrCreateSubrange(int64_t Lo, int64_t Count) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 545 | return MDSubrange::get(VMContext, Count, Lo); |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 546 | } |
| 547 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 548 | static void checkGlobalVariableScope(MDScope * Context) { |
Duncan P. N. Exon Smith | 430220f | 2015-04-06 23:34:41 +0000 | [diff] [blame] | 549 | #ifndef NDEBUG |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 550 | if (auto *CT = |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 551 | dyn_cast_or_null<MDCompositeType>(getNonCompileUnitScope(Context))) |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 552 | assert(CT->getIdentifier().empty() && |
Manman Ren | bfd2b829 | 2014-11-21 19:47:48 +0000 | [diff] [blame] | 553 | "Context of a global variable should not be a type with identifier"); |
Duncan P. N. Exon Smith | 430220f | 2015-04-06 23:34:41 +0000 | [diff] [blame] | 554 | #endif |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 555 | } |
| 556 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 557 | MDGlobalVariable *DIBuilder::createGlobalVariable( |
| 558 | MDScope *Context, StringRef Name, StringRef LinkageName, MDFile *F, |
| 559 | unsigned LineNumber, MDType *Ty, bool isLocalToUnit, Constant *Val, |
Duncan P. N. Exon Smith | dbf64acd | 2014-11-15 00:23:49 +0000 | [diff] [blame] | 560 | MDNode *Decl) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 561 | checkGlobalVariableScope(Context); |
| 562 | |
Duncan P. N. Exon Smith | b273d06 | 2015-04-16 01:37:00 +0000 | [diff] [blame] | 563 | auto *N = MDGlobalVariable::get(VMContext, cast_or_null<MDScope>(Context), |
| 564 | Name, LinkageName, F, LineNumber, |
| 565 | MDTypeRef::get(Ty), isLocalToUnit, true, Val, |
| 566 | cast_or_null<MDDerivedType>(Decl)); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 567 | AllGVs.push_back(N); |
| 568 | return N; |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 569 | } |
| 570 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 571 | MDGlobalVariable *DIBuilder::createTempGlobalVariableFwdDecl( |
| 572 | MDScope *Context, StringRef Name, StringRef LinkageName, MDFile *F, |
| 573 | unsigned LineNumber, MDType *Ty, bool isLocalToUnit, Constant *Val, |
Duncan P. N. Exon Smith | dbf64acd | 2014-11-15 00:23:49 +0000 | [diff] [blame] | 574 | MDNode *Decl) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 575 | checkGlobalVariableScope(Context); |
| 576 | |
Duncan P. N. Exon Smith | 3d2afaa | 2015-03-27 17:29:58 +0000 | [diff] [blame] | 577 | return MDGlobalVariable::getTemporary( |
Duncan P. N. Exon Smith | b273d06 | 2015-04-16 01:37:00 +0000 | [diff] [blame] | 578 | VMContext, cast_or_null<MDScope>(Context), Name, LinkageName, F, |
| 579 | LineNumber, MDTypeRef::get(Ty), isLocalToUnit, false, Val, |
| 580 | cast_or_null<MDDerivedType>(Decl)) |
| 581 | .release(); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 582 | } |
| 583 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 584 | MDLocalVariable *DIBuilder::createLocalVariable( |
| 585 | unsigned Tag, MDScope *Scope, StringRef Name, MDFile *File, unsigned LineNo, |
| 586 | MDType *Ty, bool AlwaysPreserve, unsigned Flags, unsigned ArgNo) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 587 | // FIXME: Why getNonCompileUnitScope()? |
| 588 | // FIXME: Why is "!Context" okay here? |
| 589 | // FIXME: WHy doesn't this check for a subprogram or lexical block (AFAICT |
| 590 | // the only valid scopes)? |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 591 | MDScope* Context = getNonCompileUnitScope(Scope); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 592 | |
Duncan P. N. Exon Smith | 3ec5fa6 | 2015-04-06 19:03:45 +0000 | [diff] [blame] | 593 | auto *Node = MDLocalVariable::get( |
Duncan P. N. Exon Smith | b273d06 | 2015-04-16 01:37:00 +0000 | [diff] [blame] | 594 | VMContext, Tag, cast_or_null<MDLocalScope>(Context), Name, File, LineNo, |
| 595 | MDTypeRef::get(Ty), ArgNo, Flags); |
Devang Patel | 63f83cd | 2010-12-07 23:58:00 +0000 | [diff] [blame] | 596 | if (AlwaysPreserve) { |
| 597 | // The optimizer may remove local variable. If there is an interest |
| 598 | // to preserve variable info in such situation then stash it in a |
| 599 | // named mdnode. |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 600 | MDSubprogram *Fn = getDISubprogram(Scope); |
Duncan P. N. Exon Smith | 3bfffde | 2014-10-15 16:11:41 +0000 | [diff] [blame] | 601 | assert(Fn && "Missing subprogram for local variable"); |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 602 | PreservedVariables[Fn].emplace_back(Node); |
Devang Patel | 63f83cd | 2010-12-07 23:58:00 +0000 | [diff] [blame] | 603 | } |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 604 | return Node; |
Devang Patel | 63f83cd | 2010-12-07 23:58:00 +0000 | [diff] [blame] | 605 | } |
| 606 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 607 | MDExpression* DIBuilder::createExpression(ArrayRef<uint64_t> Addr) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 608 | return MDExpression::get(VMContext, Addr); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 609 | } |
| 610 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 611 | MDExpression* DIBuilder::createExpression(ArrayRef<int64_t> Signed) { |
Duncan P. N. Exon Smith | bd75ad4 | 2015-02-09 22:13:27 +0000 | [diff] [blame] | 612 | // TODO: Remove the callers of this signed version and delete. |
| 613 | SmallVector<uint64_t, 8> Addr(Signed.begin(), Signed.end()); |
| 614 | return createExpression(Addr); |
| 615 | } |
| 616 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 617 | MDExpression* DIBuilder::createBitPieceExpression(unsigned OffsetInBytes, |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 618 | unsigned SizeInBytes) { |
| 619 | uint64_t Addr[] = {dwarf::DW_OP_bit_piece, OffsetInBytes, SizeInBytes}; |
| 620 | return MDExpression::get(VMContext, Addr); |
Duncan P. N. Exon Smith | 9affbba | 2014-10-01 21:32:12 +0000 | [diff] [blame] | 621 | } |
| 622 | |
Duncan P. N. Exon Smith | 848af38 | 2015-04-20 18:20:03 +0000 | [diff] [blame] | 623 | MDSubprogram *DIBuilder::createFunction(MDScopeRef Context, StringRef Name, |
| 624 | StringRef LinkageName, MDFile *File, |
| 625 | unsigned LineNo, MDSubroutineType *Ty, |
| 626 | bool isLocalToUnit, bool isDefinition, |
| 627 | unsigned ScopeLine, unsigned Flags, |
| 628 | bool isOptimized, Function *Fn, |
| 629 | MDNode *TParams, MDNode *Decl) { |
Manman Ren | c50fa11 | 2013-10-10 18:40:01 +0000 | [diff] [blame] | 630 | // dragonegg does not generate identifier for types, so using an empty map |
| 631 | // to resolve the context should be fine. |
| 632 | DITypeIdentifierMap EmptyMap; |
| 633 | return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File, |
| 634 | LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine, |
| 635 | Flags, isOptimized, Fn, TParams, Decl); |
| 636 | } |
| 637 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 638 | MDSubprogram* DIBuilder::createFunction(MDScope * Context, StringRef Name, |
| 639 | StringRef LinkageName, MDFile* File, |
| 640 | unsigned LineNo, MDSubroutineType* Ty, |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 641 | bool isLocalToUnit, bool isDefinition, |
| 642 | unsigned ScopeLine, unsigned Flags, |
| 643 | bool isOptimized, Function *Fn, |
| 644 | MDNode *TParams, MDNode *Decl) { |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 645 | assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type && |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 646 | "function types should be subroutines"); |
| 647 | auto *Node = MDSubprogram::get( |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 648 | VMContext, MDScopeRef::get(getNonCompileUnitScope(Context)), Name, |
| 649 | LinkageName, File, LineNo, Ty, |
Duncan P. N. Exon Smith | 35ef22c | 2015-04-15 23:19:27 +0000 | [diff] [blame] | 650 | isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, isOptimized, |
| 651 | Fn, cast_or_null<MDTuple>(TParams), cast_or_null<MDSubprogram>(Decl), |
Duncan P. N. Exon Smith | 869db50 | 2015-03-30 16:19:15 +0000 | [diff] [blame] | 652 | MDTuple::getTemporary(VMContext, None).release()); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 653 | |
| 654 | if (isDefinition) |
| 655 | AllSubprograms.push_back(Node); |
| 656 | trackIfUnresolved(Node); |
| 657 | return Node; |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 658 | } |
| 659 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 660 | MDSubprogram* |
| 661 | DIBuilder::createTempFunctionFwdDecl(MDScope * Context, StringRef Name, |
| 662 | StringRef LinkageName, MDFile* File, |
| 663 | unsigned LineNo, MDSubroutineType* Ty, |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 664 | bool isLocalToUnit, bool isDefinition, |
| 665 | unsigned ScopeLine, unsigned Flags, |
| 666 | bool isOptimized, Function *Fn, |
| 667 | MDNode *TParams, MDNode *Decl) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 668 | return MDSubprogram::getTemporary( |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 669 | VMContext, MDScopeRef::get(getNonCompileUnitScope(Context)), Name, |
| 670 | LinkageName, File, LineNo, Ty, |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 671 | isLocalToUnit, isDefinition, ScopeLine, nullptr, 0, 0, Flags, |
| 672 | isOptimized, Fn, cast_or_null<MDTuple>(TParams), |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 673 | cast_or_null<MDSubprogram>(Decl), nullptr).release(); |
Frederic Riss | 5e6bc9e | 2014-09-17 09:28:34 +0000 | [diff] [blame] | 674 | } |
| 675 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 676 | MDSubprogram * |
| 677 | DIBuilder::createMethod(MDScope *Context, StringRef Name, StringRef LinkageName, |
| 678 | MDFile *F, unsigned LineNo, MDSubroutineType *Ty, |
| 679 | bool isLocalToUnit, bool isDefinition, unsigned VK, |
| 680 | unsigned VIndex, MDType *VTableHolder, unsigned Flags, |
| 681 | bool isOptimized, Function *Fn, MDNode *TParam) { |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 682 | assert(Ty->getTag() == dwarf::DW_TAG_subroutine_type && |
David Blaikie | 5174c84 | 2013-05-22 23:22:18 +0000 | [diff] [blame] | 683 | "function types should be subroutines"); |
Eric Christopher | 5cb5632 | 2013-10-15 23:31:36 +0000 | [diff] [blame] | 684 | assert(getNonCompileUnitScope(Context) && |
| 685 | "Methods should have both a Context and a context that isn't " |
| 686 | "the compile unit."); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 687 | // FIXME: Do we want to use different scope/lines? |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 688 | auto *SP = MDSubprogram::get( |
Duncan P. N. Exon Smith | 35ef22c | 2015-04-15 23:19:27 +0000 | [diff] [blame] | 689 | VMContext, MDScopeRef::get(cast<MDScope>(Context)), Name, LinkageName, F, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 690 | LineNo, Ty, isLocalToUnit, isDefinition, LineNo, |
| 691 | MDTypeRef::get(VTableHolder), VK, VIndex, Flags, isOptimized, Fn, |
Duncan P. N. Exon Smith | b105564 | 2015-04-16 01:01:28 +0000 | [diff] [blame] | 692 | cast_or_null<MDTuple>(TParam), nullptr, nullptr); |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 693 | |
David Blaikie | 595eb44 | 2013-02-18 07:10:22 +0000 | [diff] [blame] | 694 | if (isDefinition) |
Duncan P. N. Exon Smith | 9d1cf4c | 2015-04-06 23:18:49 +0000 | [diff] [blame] | 695 | AllSubprograms.push_back(SP); |
| 696 | trackIfUnresolved(SP); |
| 697 | return SP; |
Devang Patel | b68c623 | 2010-12-08 20:42:44 +0000 | [diff] [blame] | 698 | } |
| 699 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 700 | MDNamespace* DIBuilder::createNameSpace(MDScope * Scope, StringRef Name, |
| 701 | MDFile* File, unsigned LineNo) { |
Duncan P. N. Exon Smith | a5099dc | 2015-04-06 19:49:39 +0000 | [diff] [blame] | 702 | return MDNamespace::get(VMContext, getNonCompileUnitScope(Scope), File, Name, |
| 703 | LineNo); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 704 | } |
| 705 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 706 | MDLexicalBlockFile* DIBuilder::createLexicalBlockFile(MDScope * Scope, |
| 707 | MDFile* File, |
David Blaikie | 2f3f76f | 2014-08-21 22:45:21 +0000 | [diff] [blame] | 708 | unsigned Discriminator) { |
Duncan P. N. Exon Smith | 35ef22c | 2015-04-15 23:19:27 +0000 | [diff] [blame] | 709 | return MDLexicalBlockFile::get(VMContext, Scope, File, Discriminator); |
Eric Christopher | 6647b83 | 2011-10-11 22:59:11 +0000 | [diff] [blame] | 710 | } |
| 711 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 712 | MDLexicalBlock* DIBuilder::createLexicalBlock(MDScope * Scope, MDFile* File, |
David Blaikie | 2f3f76f | 2014-08-21 22:45:21 +0000 | [diff] [blame] | 713 | unsigned Line, unsigned Col) { |
Duncan P. N. Exon Smith | e274180 | 2015-03-03 17:24:31 +0000 | [diff] [blame] | 714 | // Make these distinct, to avoid merging two lexical blocks on the same |
| 715 | // file/line/column. |
Duncan P. N. Exon Smith | a5099dc | 2015-04-06 19:49:39 +0000 | [diff] [blame] | 716 | return MDLexicalBlock::getDistinct(VMContext, getNonCompileUnitScope(Scope), |
Duncan P. N. Exon Smith | 35ef22c | 2015-04-15 23:19:27 +0000 | [diff] [blame] | 717 | File, Line, Col); |
Devang Patel | 89ea4f2 | 2010-12-08 01:50:15 +0000 | [diff] [blame] | 718 | } |
| 719 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 720 | static Value *getDbgIntrinsicValueImpl(LLVMContext &VMContext, Value *V) { |
| 721 | assert(V && "no value passed to dbg intrinsic"); |
| 722 | return MetadataAsValue::get(VMContext, ValueAsMetadata::get(V)); |
| 723 | } |
| 724 | |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 725 | static Instruction *withDebugLoc(Instruction *I, const MDLocation *DL) { |
| 726 | I->setDebugLoc(const_cast<MDLocation *>(DL)); |
| 727 | return I; |
| 728 | } |
| 729 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 730 | Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo, |
| 731 | MDExpression* Expr, const MDLocation *DL, |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 732 | Instruction *InsertBefore) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 733 | assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.declare"); |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 734 | assert(DL && "Expected debug loc"); |
| 735 | assert(DL->getScope()->getSubprogram() == |
| 736 | VarInfo->getScope()->getSubprogram() && |
| 737 | "Expected matching subprograms"); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 738 | if (!DeclareFn) |
| 739 | DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); |
| 740 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 741 | trackIfUnresolved(VarInfo); |
| 742 | trackIfUnresolved(Expr); |
| 743 | Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage), |
| 744 | MetadataAsValue::get(VMContext, VarInfo), |
| 745 | MetadataAsValue::get(VMContext, Expr)}; |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 746 | return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertBefore), DL); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 747 | } |
| 748 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 749 | Instruction *DIBuilder::insertDeclare(Value *Storage, MDLocalVariable* VarInfo, |
| 750 | MDExpression* Expr, const MDLocation *DL, |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 751 | BasicBlock *InsertAtEnd) { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 752 | assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.declare"); |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 753 | assert(DL && "Expected debug loc"); |
| 754 | assert(DL->getScope()->getSubprogram() == |
| 755 | VarInfo->getScope()->getSubprogram() && |
| 756 | "Expected matching subprograms"); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 757 | if (!DeclareFn) |
| 758 | DeclareFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_declare); |
| 759 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 760 | trackIfUnresolved(VarInfo); |
| 761 | trackIfUnresolved(Expr); |
| 762 | Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, Storage), |
| 763 | MetadataAsValue::get(VMContext, VarInfo), |
| 764 | MetadataAsValue::get(VMContext, Expr)}; |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 765 | |
| 766 | // If this block already has a terminator then insert this intrinsic |
| 767 | // before the terminator. |
| 768 | if (TerminatorInst *T = InsertAtEnd->getTerminator()) |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 769 | return withDebugLoc(CallInst::Create(DeclareFn, Args, "", T), DL); |
| 770 | return withDebugLoc(CallInst::Create(DeclareFn, Args, "", InsertAtEnd), DL); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 771 | } |
| 772 | |
Devang Patel | 9b41273 | 2011-02-22 18:56:12 +0000 | [diff] [blame] | 773 | Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 774 | MDLocalVariable* VarInfo, |
| 775 | MDExpression* Expr, |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 776 | const MDLocation *DL, |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 777 | Instruction *InsertBefore) { |
| 778 | assert(V && "no value passed to dbg.value"); |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 779 | assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.value"); |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 780 | assert(DL && "Expected debug loc"); |
| 781 | assert(DL->getScope()->getSubprogram() == |
| 782 | VarInfo->getScope()->getSubprogram() && |
| 783 | "Expected matching subprograms"); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 784 | if (!ValueFn) |
| 785 | ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); |
| 786 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 787 | trackIfUnresolved(VarInfo); |
| 788 | trackIfUnresolved(Expr); |
| 789 | Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V), |
| 790 | ConstantInt::get(Type::getInt64Ty(VMContext), Offset), |
| 791 | MetadataAsValue::get(VMContext, VarInfo), |
| 792 | MetadataAsValue::get(VMContext, Expr)}; |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 793 | return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertBefore), DL); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 794 | } |
| 795 | |
Devang Patel | 9b41273 | 2011-02-22 18:56:12 +0000 | [diff] [blame] | 796 | Instruction *DIBuilder::insertDbgValueIntrinsic(Value *V, uint64_t Offset, |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 797 | MDLocalVariable* VarInfo, |
| 798 | MDExpression* Expr, |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 799 | const MDLocation *DL, |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 800 | BasicBlock *InsertAtEnd) { |
| 801 | assert(V && "no value passed to dbg.value"); |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 802 | assert(VarInfo && "empty or invalid MDLocalVariable* passed to dbg.value"); |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 803 | assert(DL && "Expected debug loc"); |
| 804 | assert(DL->getScope()->getSubprogram() == |
| 805 | VarInfo->getScope()->getSubprogram() && |
| 806 | "Expected matching subprograms"); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 807 | if (!ValueFn) |
| 808 | ValueFn = Intrinsic::getDeclaration(&M, Intrinsic::dbg_value); |
| 809 | |
Duncan P. N. Exon Smith | 5bf8fef | 2014-12-09 18:38:53 +0000 | [diff] [blame] | 810 | trackIfUnresolved(VarInfo); |
| 811 | trackIfUnresolved(Expr); |
| 812 | Value *Args[] = {getDbgIntrinsicValueImpl(VMContext, V), |
| 813 | ConstantInt::get(Type::getInt64Ty(VMContext), Offset), |
| 814 | MetadataAsValue::get(VMContext, VarInfo), |
| 815 | MetadataAsValue::get(VMContext, Expr)}; |
Duncan P. N. Exon Smith | cd1aecf | 2015-04-15 21:18:07 +0000 | [diff] [blame] | 816 | |
| 817 | return withDebugLoc(CallInst::Create(ValueFn, Args, "", InsertAtEnd), DL); |
Devang Patel | 746660f | 2010-12-07 23:25:47 +0000 | [diff] [blame] | 818 | } |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 819 | |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 820 | void DIBuilder::replaceVTableHolder(MDCompositeType* &T, MDCompositeType* VTableHolder) { |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 821 | { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 822 | TypedTrackingMDRef<MDCompositeType> N(T); |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 823 | N->replaceVTableHolder(MDTypeRef::get(VTableHolder)); |
| 824 | T = N.get(); |
| 825 | } |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 826 | |
| 827 | // If this didn't create a self-reference, just return. |
| 828 | if (T != VTableHolder) |
| 829 | return; |
| 830 | |
Adrian Prantl | 18a25b0 | 2015-02-11 17:45:10 +0000 | [diff] [blame] | 831 | // Look for unresolved operands. T will drop RAUW support, orphaning any |
| 832 | // cycles underneath it. |
| 833 | if (T->isResolved()) |
| 834 | for (const MDOperand &O : T->operands()) |
| 835 | if (auto *N = dyn_cast_or_null<MDNode>(O)) |
| 836 | trackIfUnresolved(N); |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 837 | } |
| 838 | |
Duncan P. N. Exon Smith | aa861aa | 2015-04-21 20:07:38 +0000 | [diff] [blame] | 839 | void DIBuilder::replaceArrays(MDCompositeType *&T, DebugNodeArray Elements, |
| 840 | DebugNodeArray TParams) { |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 841 | { |
Duncan P. N. Exon Smith | 0208353 | 2015-04-16 16:36:23 +0000 | [diff] [blame] | 842 | TypedTrackingMDRef<MDCompositeType> N(T); |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 843 | if (Elements) |
Duncan P. N. Exon Smith | 000fa2c | 2015-04-07 04:14:33 +0000 | [diff] [blame] | 844 | N->replaceElements(Elements); |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 845 | if (TParams) |
Duncan P. N. Exon Smith | cb9b43b | 2015-04-07 17:30:52 +0000 | [diff] [blame] | 846 | N->replaceTemplateParams(MDTemplateParameterArray(TParams)); |
Duncan P. N. Exon Smith | 8d33fdc | 2015-04-07 04:12:02 +0000 | [diff] [blame] | 847 | T = N.get(); |
| 848 | } |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 849 | |
| 850 | // If T isn't resolved, there's no problem. |
| 851 | if (!T->isResolved()) |
| 852 | return; |
| 853 | |
| 854 | // If "T" is resolved, it may be due to a self-reference cycle. Track the |
| 855 | // arrays explicitly if they're unresolved, or else the cycles will be |
| 856 | // orphaned. |
| 857 | if (Elements) |
Duncan P. N. Exon Smith | 1134473 | 2015-04-07 16:50:39 +0000 | [diff] [blame] | 858 | trackIfUnresolved(Elements.get()); |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 859 | if (TParams) |
Duncan P. N. Exon Smith | 1134473 | 2015-04-07 16:50:39 +0000 | [diff] [blame] | 860 | trackIfUnresolved(TParams.get()); |
Duncan P. N. Exon Smith | 97f07c2 | 2014-12-18 00:46:16 +0000 | [diff] [blame] | 861 | } |