Index: include/llvm/Bitcode/LLVMBitCodes.h =================================================================== --- include/llvm/Bitcode/LLVMBitCodes.h +++ include/llvm/Bitcode/LLVMBitCodes.h @@ -255,6 +255,7 @@ METADATA_MACRO = 33, // [distinct, macinfo, line, name, value] METADATA_MACRO_FILE = 34, // [distinct, macinfo, line, file, ...] METADATA_STRINGS = 35, // [count, offset] blob([lengths][chars]) + METADATA_TYPE_INDEX = 36, // [index] }; // The constants block (CONSTANTS_BLOCK_ID) describes emission for each Index: include/llvm/IR/DIBuilder.h =================================================================== --- include/llvm/IR/DIBuilder.h +++ include/llvm/IR/DIBuilder.h @@ -508,7 +508,7 @@ /// \param TParams Function template parameters. DISubprogram *createFunction(DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, - unsigned LineNo, DISubroutineType *Ty, + unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags = 0, bool isOptimized = false, @@ -519,7 +519,7 @@ /// except that the resulting DbgNode is meant to be RAUWed. DISubprogram *createTempFunctionFwdDecl( DIScope *Scope, StringRef Name, StringRef LinkageName, DIFile *File, - unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, + unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags = 0, bool isOptimized = false, DITemplateParameterArray TParams = nullptr, DISubprogram *Decl = nullptr); @@ -556,7 +556,7 @@ /// \param TParams Function template parameters. DISubprogram * createMethod(DIScope *Scope, StringRef Name, StringRef LinkageName, - DIFile *File, unsigned LineNo, DISubroutineType *Ty, + DIFile *File, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned Virtuality = 0, unsigned VTableIndex = 0, DIType *VTableHolder = nullptr, unsigned Flags = 0, bool isOptimized = false, Index: include/llvm/IR/DebugInfoMetadata.h =================================================================== --- include/llvm/IR/DebugInfoMetadata.h +++ include/llvm/IR/DebugInfoMetadata.h @@ -59,7 +59,8 @@ /// \brief Construct from a raw pointer. explicit TypedDINodeRef(const Metadata *MD) : MD(MD) { - assert((!MD || isa(MD) || isa(MD)) && "Expected valid ref"); + assert((!MD || isa(MD) || isa(MD) || isa(MD)) && + "Expected valid ref"); } template @@ -86,6 +87,8 @@ if (auto *Typed = dyn_cast(MD)) return const_cast(Typed); + assert(!isa(MD) && "attempted to resolve a type index"); + auto *S = cast(MD); auto I = Map.find(S); assert(I != Map.end() && "Missing identifier in type map"); @@ -1252,7 +1255,7 @@ static DISubprogram * getImpl(LLVMContext &Context, DIScopeRef Scope, StringRef Name, StringRef LinkageName, DIFile *File, unsigned Line, - DISubroutineType *Type, bool IsLocalToUnit, bool IsDefinition, + DITypeRef Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality, unsigned VirtualIndex, unsigned Flags, bool IsOptimized, DICompileUnit *Unit, DITemplateParameterArray TemplateParams, @@ -1286,7 +1289,7 @@ public: DEFINE_MDNODE_GET(DISubprogram, (DIScopeRef Scope, StringRef Name, StringRef LinkageName, - DIFile *File, unsigned Line, DISubroutineType *Type, + DIFile *File, unsigned Line, DITypeRef Type, bool IsLocalToUnit, bool IsDefinition, unsigned ScopeLine, DITypeRef ContainingType, unsigned Virtuality, unsigned VirtualIndex, unsigned Flags, bool IsOptimized, @@ -1360,9 +1363,7 @@ MDString *getRawName() const { return getOperandAs(2); } MDString *getRawLinkageName() const { return getOperandAs(4); } - DISubroutineType *getType() const { - return cast_or_null(getRawType()); - } + DITypeRef getType() const { return DITypeRef(getRawType()); } DITypeRef getContainingType() const { return DITypeRef(getRawContainingType()); } @@ -2386,6 +2387,25 @@ } }; +/// Represents a type in a DITypeStream at the given index. Uses the +/// DITypeStream in the current CU. Doesn't contain metadata operands, so this +/// inherits directly from Metadata. +class DITypeIndex : public Metadata { + DITypeIndex(unsigned Index) : Metadata(DITypeIndexKind, Uniqued) { + SubclassData32 = Index; + } + ~DITypeIndex() = default; + +public: + unsigned getIndex() const { return SubclassData32; } + + static DITypeIndex *get(LLVMContext &Context, unsigned Index); + + static bool classof(const Metadata *MD) { + return MD->getMetadataID() == DITypeIndexKind; + } +}; + } // end namespace llvm #undef DEFINE_MDNODE_GET_UNPACK_IMPL Index: include/llvm/IR/Metadata.h =================================================================== --- include/llvm/IR/Metadata.h +++ include/llvm/IR/Metadata.h @@ -87,7 +87,8 @@ LocalAsMetadataKind, MDStringKind, DIMacroKind, - DIMacroFileKind + DIMacroFileKind, + DITypeIndexKind, }; protected: Index: include/llvm/IR/Metadata.def =================================================================== --- include/llvm/IR/Metadata.def +++ include/llvm/IR/Metadata.def @@ -111,6 +111,7 @@ HANDLE_SPECIALIZED_MDNODE_BRANCH(DIMacroNode) HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacro) HANDLE_SPECIALIZED_MDNODE_LEAF_UNIQUABLE(DIMacroFile) +HANDLE_METADATA_LEAF(DITypeIndex) #undef HANDLE_METADATA #undef HANDLE_METADATA_LEAF Index: lib/AsmParser/LLParser.h =================================================================== --- lib/AsmParser/LLParser.h +++ lib/AsmParser/LLParser.h @@ -287,6 +287,7 @@ bool ParseStandaloneMetadata(); bool ParseNamedMetadata(); bool ParseMDString(MDString *&Result); + bool ParseDITypeIndex(DITypeIndex *&Result); bool ParseMDNodeID(MDNode *&Result); bool ParseUnnamedAttrGrp(); bool ParseFnAttributeValuePairs(AttrBuilder &B, Index: lib/AsmParser/LLParser.cpp =================================================================== --- lib/AsmParser/LLParser.cpp +++ lib/AsmParser/LLParser.cpp @@ -598,6 +598,19 @@ return false; } +// DITypeIndex: +// ::= '!DITypeIndex' '(' uint32 ')' +bool LLParser::ParseDITypeIndex(DITypeIndex *&Result) { + assert(Lex.getKind() == lltok::MetadataVar); + Lex.Lex(); + unsigned Index; + if (ParseToken(lltok::lparen, "Expected '(' here") || ParseUInt32(Index) || + ParseToken(lltok::rparen, "Expected ')' here")) + return true; + Result = DITypeIndex::get(Context, Index); + return false; +} + // MDNode: // ::= '!' MDNodeNumber bool LLParser::ParseMDNodeID(MDNode *&Result) { @@ -4275,6 +4288,16 @@ /// ::= !DILocation(...) bool LLParser::ParseMetadata(Metadata *&MD, PerFunctionState *PFS) { if (Lex.getKind() == lltok::MetadataVar) { + // Handle type indices similar to MDString. They appear as literals, and are + // not referred to by number as is done for MDNodes. + if (Lex.getStrVal() == "DITypeIndex") { + DITypeIndex *TI; + if (ParseDITypeIndex(TI)) + return true; + MD = TI; + return false; + } + MDNode *N; if (ParseSpecializedMDNode(N)) return true; Index: lib/Bitcode/Reader/BitcodeReader.cpp =================================================================== --- lib/Bitcode/Reader/BitcodeReader.cpp +++ lib/Bitcode/Reader/BitcodeReader.cpp @@ -2460,6 +2460,14 @@ MetadataList.assignValue(MD, NextMetadataNo++); break; } + case bitc::METADATA_TYPE_INDEX: { + if (Record.size() != 1 || Record[0] > UINT_MAX) + return error("Invalid record"); + uint32_t Index = Record[0]; + Metadata *MD = DITypeIndex::get(Context, Index); + MetadataList.assignValue(MD, NextMetadataNo++); + break; + } case bitc::METADATA_STRINGS: if (std::error_code EC = parseMetadataStrings(Record, Blob, NextMetadataNo)) Index: lib/Bitcode/Writer/BitcodeWriter.cpp =================================================================== --- lib/Bitcode/Writer/BitcodeWriter.cpp +++ lib/Bitcode/Writer/BitcodeWriter.cpp @@ -886,6 +886,14 @@ Record.clear(); } +static void writeDITypeIndex(const DITypeIndex *TI, BitstreamWriter &Stream, + SmallVectorImpl &Record) { + // Mimic an MDNode with a value as one operand. + Record.push_back(TI->getIndex()); + Stream.EmitRecord(bitc::METADATA_TYPE_INDEX, Record, 0); + Record.clear(); +} + static void writeMDTuple(const MDTuple *N, const ValueEnumerator &VE, BitstreamWriter &Stream, SmallVectorImpl &Record, unsigned Abbrev) { @@ -1428,6 +1436,9 @@ continue; #include "llvm/IR/Metadata.def" } + } else if (const DITypeIndex *TI = dyn_cast(MD)) { + writeDITypeIndex(TI, Stream, Record); + continue; } writeValueAsMetadata(cast(MD), VE, Stream, Record); } Index: lib/Bitcode/Writer/ValueEnumerator.cpp =================================================================== --- lib/Bitcode/Writer/ValueEnumerator.cpp +++ lib/Bitcode/Writer/ValueEnumerator.cpp @@ -601,8 +601,8 @@ void ValueEnumerator::EnumerateMetadata(unsigned F, const Metadata *MD) { assert( - (isa(MD) || isa(MD) || isa(MD)) && - "Invalid metadata kind"); + (isa(MD) || isa(MD) || isa(MD)) || + isa(MD) && "Invalid metadata kind"); // Insert a dummy ID to block the co-recursive call to // EnumerateMDNodeOperands() from re-visiting MD in a cyclic graph. Index: lib/CodeGen/AsmPrinter/CodeViewDebug.cpp =================================================================== --- lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -709,6 +709,12 @@ OS.AddComment("Record kind: S_LOCAL"); OS.EmitIntValue(unsigned(SymbolRecordKind::S_LOCAL), 2); + // Pull the type index out of the type field. If the frontend did not provide + // a DITypeIndex, emit zero for "no type". + unsigned TI = unsigned(SimpleTypeKind::None); + if (auto *DTI = dyn_cast_or_null(Var.DIVar->getType())) + TI = DTI->getIndex(); + uint16_t Flags = 0; if (Var.DIVar->isParameter()) Flags |= LocalSym::IsParameter; @@ -716,7 +722,7 @@ Flags |= LocalSym::IsOptimizedOut; OS.AddComment("TypeIndex"); - OS.EmitIntValue(TypeIndex::Int32().getIndex(), 4); + OS.EmitIntValue(TI, 4); OS.AddComment("Flags"); OS.EmitIntValue(Flags, 2); // Truncate the name so we won't overflow the record length field. Index: lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -586,7 +586,10 @@ DIE &ScopeDIE = updateSubprogramScopeDIE(Sub); // If this is a variadic function, add an unspecified parameter. - DITypeRefArray FnArgs = Sub->getType()->getTypeArray(); + DITypeRefArray FnArgs; + if (DISubroutineType *FnTy = + cast_or_null(resolve(Sub->getType()))) + FnArgs = FnTy->getTypeArray(); // Collect lexical scope children first. // ObjectPointer might be a local (non-argument) local variable if it's a Index: lib/CodeGen/AsmPrinter/DwarfUnit.cpp =================================================================== --- lib/CodeGen/AsmPrinter/DwarfUnit.cpp +++ lib/CodeGen/AsmPrinter/DwarfUnit.cpp @@ -1206,7 +1206,8 @@ addFlag(SPDie, dwarf::DW_AT_prototyped); DITypeRefArray Args; - if (const DISubroutineType *SPTy = SP->getType()) + if (const DISubroutineType *SPTy = + cast_or_null(resolve(SP->getType()))) Args = SPTy->getTypeArray(); // Add a return type. If this is a type like a C/C++ void type we don't add a Index: lib/IR/AsmWriter.cpp =================================================================== --- lib/IR/AsmWriter.cpp +++ lib/IR/AsmWriter.cpp @@ -2021,6 +2021,16 @@ return; } + if (const auto *TI = dyn_cast(MD)) { + Out << "!DITypeIndex("; + if (TI->getIndex() == 0) + Out << '0'; + else + Out << 'u' << format_hex(TI->getIndex(), 0, /*Upper=*/true); + Out << ')'; + return; + } + auto *V = cast(MD); assert(TypePrinter && "TypePrinter required for metadata values"); assert((FromValue || !isa(V)) && Index: lib/IR/DIBuilder.cpp =================================================================== --- lib/IR/DIBuilder.cpp +++ lib/IR/DIBuilder.cpp @@ -673,8 +673,8 @@ // to resolve the context should be fine. DITypeIdentifierMap EmptyMap; return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File, - LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine, - Flags, isOptimized, TParams, Decl); + LineNo, DITypeRef(Ty), isLocalToUnit, isDefinition, + ScopeLine, Flags, isOptimized, TParams, Decl); } template @@ -686,7 +686,7 @@ DISubprogram *DIBuilder::createFunction( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, - unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, + unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl) { auto *Node = getSubprogram( @@ -704,7 +704,7 @@ DISubprogram *DIBuilder::createTempFunctionFwdDecl( DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File, - unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit, + unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized, DITemplateParameterArray TParams, DISubprogram *Decl) { return DISubprogram::getTemporary( @@ -717,7 +717,7 @@ DISubprogram * DIBuilder::createMethod(DIScope *Context, StringRef Name, StringRef LinkageName, - DIFile *F, unsigned LineNo, DISubroutineType *Ty, + DIFile *F, unsigned LineNo, DITypeRef Ty, bool isLocalToUnit, bool isDefinition, unsigned VK, unsigned VIndex, DIType *VTableHolder, unsigned Flags, bool isOptimized, DITemplateParameterArray TParams) { Index: lib/IR/DebugInfo.cpp =================================================================== --- lib/IR/DebugInfo.cpp +++ lib/IR/DebugInfo.cpp @@ -179,7 +179,7 @@ if (!addSubprogram(SP)) return; processScope(SP->getScope().resolve(TypeIdentifierMap)); - processType(SP->getType()); + processType(SP->getType().resolve(TypeIdentifierMap)); for (auto *Element : SP->getTemplateParams()) { if (auto *TType = dyn_cast(Element)) { processType(TType->getType().resolve(TypeIdentifierMap)); Index: lib/IR/DebugInfoMetadata.cpp =================================================================== --- lib/IR/DebugInfoMetadata.cpp +++ lib/IR/DebugInfoMetadata.cpp @@ -567,3 +567,12 @@ DEFINE_GETIMPL_STORE(DIMacroFile, (MIType, Line), Ops); } +DITypeIndex *DITypeIndex::get(LLVMContext &Context, unsigned Index) { + DITypeIndex *&Slot = Context.pImpl->TypeIndexCache[Index]; + if (!Slot) { + void *Mem = Context.pImpl->TypeAllocator.Allocate(sizeof(DITypeIndex), + alignof(DITypeIndex)); + Slot = new (Mem) DITypeIndex(Index); + } + return Slot; +} Index: lib/IR/LLVMContextImpl.h =================================================================== --- lib/IR/LLVMContextImpl.h +++ lib/IR/LLVMContextImpl.h @@ -1014,6 +1014,7 @@ StringMap MDStringCache; DenseMap ValuesAsMetadata; DenseMap MetadataAsValues; + DenseMap TypeIndexCache; DenseMap ValueNames; Index: lib/IR/Metadata.cpp =================================================================== --- lib/IR/Metadata.cpp +++ lib/IR/Metadata.cpp @@ -419,6 +419,7 @@ return Entry->first(); } + //===----------------------------------------------------------------------===// // MDNode implementation. // Index: lib/IR/Verifier.cpp =================================================================== --- lib/IR/Verifier.cpp +++ lib/IR/Verifier.cpp @@ -771,7 +771,7 @@ /// \brief Check if a value can be a reference to a type. bool Verifier::isTypeRef(const MDNode &N, const Metadata *MD) { - return !MD || isValidUUID(N, MD) || isa(MD); + return !MD || isValidUUID(N, MD) || isa(MD) || isa(MD); } /// \brief Check if a value can be a ScopeRef. @@ -986,7 +986,8 @@ if (auto *F = N.getRawFile()) Assert(isa(F), "invalid file", &N, F); if (auto *T = N.getRawType()) - Assert(isa(T), "invalid subroutine type", &N, T); + Assert(isa(T) || isa(T), + "invalid subroutine type", &N, T); Assert(isTypeRef(N, N.getRawContainingType()), "invalid containing type", &N, N.getRawContainingType()); if (auto *Params = N.getRawTemplateParams()) Index: test/DebugInfo/COFF/local-constant.ll =================================================================== --- test/DebugInfo/COFF/local-constant.ll +++ test/DebugInfo/COFF/local-constant.ll @@ -58,7 +58,7 @@ !5 = !DISubroutineType(types: !6) !6 = !{null} !7 = !{!8} -!8 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 3, type: !9) +!8 = !DILocalVariable(name: "x", scope: !4, file: !1, line: 3, type: !DITypeIndex(u0x74)) !9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !10 = !{i32 2, !"CodeView", i32 1} !11 = !{i32 2, !"Debug Info Version", i32 3} Index: test/DebugInfo/COFF/local-variables.ll =================================================================== --- test/DebugInfo/COFF/local-variables.ll +++ test/DebugInfo/COFF/local-variables.ll @@ -290,7 +290,7 @@ !12 = !{i32 2, !"Debug Info Version", i32 3} !13 = !{i32 1, !"PIC Level", i32 2} !14 = !{!"clang version 3.9.0 "} -!15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !7) +!15 = !DILocalVariable(name: "v", scope: !8, file: !1, line: 4, type: !DITypeIndex(u0x74)) !16 = !DIExpression() !17 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !18) !18 = distinct !DILocation(line: 14, column: 5, scope: !19) @@ -299,16 +299,16 @@ !21 = !DILocation(line: 4, column: 7, scope: !8, inlinedAt: !22) !22 = distinct !DILocation(line: 10, column: 5, scope: !23) !23 = distinct !DILexicalBlock(scope: !20, file: !1, line: 8, column: 14) -!24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !7) +!24 = !DILocalVariable(name: "param", arg: 1, scope: !4, file: !1, line: 7, type: !DITypeIndex(u0x74)) !25 = !DILocation(line: 7, column: 23, scope: !4) !26 = !DILocation(line: 8, column: 7, scope: !20) !27 = !DILocation(line: 8, column: 7, scope: !4) -!28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !7) +!28 = !DILocalVariable(name: "a", scope: !23, file: !1, line: 9, type: !DITypeIndex(u0x74)) !29 = !DILocation(line: 9, column: 9, scope: !23) !30 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !22) !31 = !DILocation(line: 11, column: 5, scope: !23) !32 = !DILocation(line: 12, column: 3, scope: !23) -!33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !7) +!33 = !DILocalVariable(name: "b", scope: !19, file: !1, line: 13, type: !DITypeIndex(u0x74)) !34 = !DILocation(line: 13, column: 9, scope: !19) !35 = !DILocation(line: 5, column: 3, scope: !8, inlinedAt: !18) !36 = !DILocation(line: 15, column: 5, scope: !19) Index: test/DebugInfo/COFF/register-variables.ll =================================================================== --- test/DebugInfo/COFF/register-variables.ll +++ test/DebugInfo/COFF/register-variables.ll @@ -247,22 +247,21 @@ !6 = !{null, !7} !7 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !8 = !{!9, !10, !13, !14} -!9 = !DILocalVariable(name: "p", arg: 1, scope: !4, file: !1, line: 9, type: !7) -!10 = !DILocalVariable(name: "a", scope: !11, file: !1, line: 11, type: !7) +!9 = !DILocalVariable(name: "p", arg: 1, scope: !4, file: !1, line: 9, type: !DITypeIndex(u0x74)) +!10 = !DILocalVariable(name: "a", scope: !11, file: !1, line: 11, type: !DITypeIndex(u0x74)) !11 = distinct !DILexicalBlock(scope: !12, file: !1, line: 10, column: 10) !12 = distinct !DILexicalBlock(scope: !4, file: !1, line: 10, column: 7) -!13 = !DILocalVariable(name: "b", scope: !11, file: !1, line: 12, type: !7) -!14 = !DILocalVariable(name: "c", scope: !15, file: !1, line: 15, type: !7) +!13 = !DILocalVariable(name: "b", scope: !11, file: !1, line: 12, type: !DITypeIndex(u0x74)) +!14 = !DILocalVariable(name: "c", scope: !15, file: !1, line: 15, type: !DITypeIndex(u0x74)) !15 = distinct !DILexicalBlock(scope: !12, file: !1, line: 14, column: 10) !16 = distinct !DISubprogram(name: "inlineinc", scope: !1, file: !1, line: 4, type: !17, isLocal: true, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: true, unit: !0, variables: !19) !17 = !DISubroutineType(types: !18) !18 = !{!7, !7} !19 = !{!20, !21} -!20 = !DILocalVariable(name: "a", arg: 1, scope: !16, file: !1, line: 4, type: !7) -!21 = !DILocalVariable(name: "b", scope: !16, file: !1, line: 5, type: !7) +!20 = !DILocalVariable(name: "a", arg: 1, scope: !16, file: !1, line: 4, type: !DITypeIndex(u0x74)) +!21 = !DILocalVariable(name: "b", scope: !16, file: !1, line: 5, type: !DITypeIndex(u0x74)) !22 = !{!23} -!23 = !DIGlobalVariable(name: "x", scope: !0, file: !1, line: 1, type: !24, isLocal: false, isDefinition: true, variable: i32* @x) -!24 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !7) +!23 = !DIGlobalVariable(name: "x", scope: !0, file: !1, line: 1, type: !DITypeIndex(u0x74), isLocal: false, isDefinition: true, variable: i32* @x) !25 = !{i32 2, !"CodeView", i32 1} !26 = !{i32 2, !"Debug Info Version", i32 3} !27 = !{i32 1, !"PIC Level", i32 2} Index: unittests/IR/IRBuilderTest.cpp =================================================================== --- unittests/IR/IRBuilderTest.cpp +++ unittests/IR/IRBuilderTest.cpp @@ -343,12 +343,12 @@ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/", "llvm-cobol74", true, "", 0); auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None)); - auto SP = - DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1, 0, true); + auto SP = DIB.createFunction(CU, "foo", "", File, 1, DITypeRef(Type), false, + true, 1, 0, true); F->setSubprogram(SP); AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty()); - auto BarSP = - DIB.createFunction(CU, "bar", "", File, 1, Type, false, true, 1, 0, true); + auto BarSP = DIB.createFunction(CU, "bar", "", File, 1, DITypeRef(Type), + false, true, 1, 0, true); auto BadScope = DIB.createLexicalBlockFile(BarSP, File, 0); I->setDebugLoc(DebugLoc::get(2, 0, BadScope)); DIB.finalize(); @@ -395,8 +395,8 @@ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C_plus_plus_11, "tmp.cpp", "/", "", true, "", 0); auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None)); - auto SP = - DIB.createFunction(CU, "foo", "foo", File, 1, SPType, false, true, 1); + auto SP = DIB.createFunction(CU, "foo", "foo", File, 1, DITypeRef(SPType), + false, true, 1); DebugLoc DL1 = DILocation::get(Ctx, 2, 0, SP); DebugLoc DL2 = DILocation::get(Ctx, 3, 0, SP); Index: unittests/IR/MetadataTest.cpp =================================================================== --- unittests/IR/MetadataTest.cpp +++ unittests/IR/MetadataTest.cpp @@ -1404,7 +1404,7 @@ StringRef LinkageName = "linkage"; DIFile *File = getFile(); unsigned Line = 2; - DISubroutineType *Type = getSubroutineType(); + DITypeRef Type = DITypeRef(getSubroutineType()); bool IsLocalToUnit = false; bool IsDefinition = true; unsigned ScopeLine = 3; @@ -1475,7 +1475,7 @@ VirtualIndex, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables)); EXPECT_NE(N, DISubprogram::get(Context, Scope, Name, LinkageName, File, Line, - getSubroutineType(), IsLocalToUnit, + DITypeRef(getSubroutineType()), IsLocalToUnit, IsDefinition, ScopeLine, ContainingType, Virtuality, VirtualIndex, Flags, IsOptimized, Unit, TemplateParams, Declaration, Variables)); Index: unittests/Transforms/Utils/Cloning.cpp =================================================================== --- unittests/Transforms/Utils/Cloning.cpp +++ unittests/Transforms/Utils/Cloning.cpp @@ -229,8 +229,7 @@ // Function DI auto *File = DBuilder.createFile("filename.c", "/file/dir/"); DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None); - DISubroutineType *FuncType = - DBuilder.createSubroutineType(ParamTypes); + DITypeRef FuncType(DBuilder.createSubroutineType(ParamTypes)); auto *CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c", "/file/dir", "CloneFunc", false, "", 0); @@ -420,7 +419,7 @@ // Create debug info auto *File = DBuilder.createFile("filename.c", "/file/dir/"); DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None); - DISubroutineType *DFuncType = DBuilder.createSubroutineType(ParamTypes); + DITypeRef DFuncType(DBuilder.createSubroutineType(ParamTypes)); auto *CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c", "/file/dir", "CloneModule", false, "", 0);