[DebugInfo][CallSites] Remove decl subprograms from 'retainedTypes:'

After the D70350, the retainedTypes: isn't being used for the purpose
of call site debug info for extern calls, so it is safe to delete it
from IR representation.
We are also adding a test to ensure the subprogram isn't stored within
the retainedTypes: from corresponding DICompileUnit.

Differential Revision: https://reviews.llvm.org/D80369
This commit is contained in:
Djordje Todorovic 2020-05-27 13:58:21 +02:00
parent b6d23f2efc
commit 40a3fcb05c
5 changed files with 21 additions and 24 deletions

View File

@ -3900,7 +3900,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
if (IsDeclForCallSite)
Fn->setSubprogram(SP);
DBuilder.retainType(SP);
DBuilder.finalizeSubprogram(SP);
}
void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,

View File

@ -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"

View File

@ -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:

View File

@ -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<void>"
// 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<void>"
// 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")

View File

@ -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"