Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -3871,7 +3871,7 @@ if (IsDeclForCallSite) Fn->setSubprogram(SP); - DBuilder.retainType(SP); + DBuilder.finalizeSubprogram(SP); } void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke, Index: clang/test/CodeGen/debug-info-extern-call.c =================================================================== --- clang/test/CodeGen/debug-info-extern-call.c +++ clang/test/CodeGen/debug-info-extern-call.c @@ -1,6 +1,10 @@ // When entry values are emitted, expect a subprogram for extern decls so that // the dwarf generator can describe call site parameters at extern call sites. // +// Initial implementation relied on the 'retainedTypes:' from the corresponding +// DICompileUnit, so we also ensure that we do not store the extern declaration +// subprogram into the 'retainedTypes:'. +// // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \ // RUN: | FileCheck %s -check-prefix=DECLS-FOR-EXTERN @@ -17,6 +21,8 @@ // RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \ // RUN: | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN +// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]] +// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{ // DECLS-FOR-EXTERN: !DISubprogram(name: "fn1" // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp" // DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name" Index: clang/test/Modules/DebugInfoTransitiveImport.m =================================================================== --- clang/test/Modules/DebugInfoTransitiveImport.m +++ clang/test/Modules/DebugInfoTransitiveImport.m @@ -12,10 +12,10 @@ // Definition of left: // CHECK: !DICompileUnit({{.*}}dwoId: -// CHECK: ![[LEFT:[0-9]+]] = !DIFile({{.*}}diamond_left.h // CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration, -// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[LEFT]], line: 3) +// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[LEFT:.*]], line: 3) // CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top" +// CHECK: ![[LEFT]] = !DIFile({{.*}}diamond_left.h // Skeleton for top: // CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}diamond_top{{.*}}dwoId: Index: clang/test/Modules/ModuleDebugInfo.cpp =================================================================== --- clang/test/Modules/ModuleDebugInfo.cpp +++ clang/test/Modules/ModuleDebugInfo.cpp @@ -51,15 +51,6 @@ // CHECK-SAME: ) // CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true) -// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B", -// no mangled name here yet. - -// This type is anchored by a function parameter. -// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A" -// CHECK-SAME: elements: -// CHECK-SAME: templateParams: -// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") - // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct" // CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE") @@ -85,6 +76,12 @@ // CHECK-SAME: templateParams: // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE") +// This type is anchored by a function parameter. +// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A" +// CHECK-SAME: elements: +// CHECK-SAME: templateParams: +// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE") + // CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation" // no mangled name here yet. @@ -93,6 +90,9 @@ // CHECK-SAME: flags: DIFlagFwdDecl // CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE") +// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B", +// no mangled name here yet. + // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual" // CHECK-SAME: elements: // CHECK-SAME: identifier: "_ZTS7Virtual") Index: clang/test/Modules/ModuleDebugInfo.m =================================================================== --- clang/test/Modules/ModuleDebugInfo.m +++ clang/test/Modules/ModuleDebugInfo.m @@ -36,19 +36,13 @@ // CHECK-NOT: name: // CHECK-SAME: elements: -// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]", -// CHECK-SAME: scope: ![[MODULE]], +// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", +// CHECK-SAME: scope: ![[MODULE]], // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK-SAME: scope: ![[MODULE]], // CHECK-SAME: elements -// The forward declaration should not be in the module scope. -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file - -// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", -// CHECK-SAME: scope: ![[MODULE]], - // CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars", // CHECK-SAME: scope: ![[MODULE]], // CHECK-SAME: elements @@ -85,11 +79,8 @@ // The output order is sublty different for module vs. pch, // so these are checked separately: // -// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]" -// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]" +// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass", // CHECK2: !DIObjCProperty(name: "property", // CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar" -// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]" -// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl", // CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"