Skip to content

Commit 40a3fcb

Browse files
author
Djordje Todorovic
committed
[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
1 parent b6d23f2 commit 40a3fcb

File tree

5 files changed

+21
-24
lines changed

5 files changed

+21
-24
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3900,7 +3900,7 @@ void CGDebugInfo::EmitFunctionDecl(GlobalDecl GD, SourceLocation Loc,
39003900
if (IsDeclForCallSite)
39013901
Fn->setSubprogram(SP);
39023902

3903-
DBuilder.retainType(SP);
3903+
DBuilder.finalizeSubprogram(SP);
39043904
}
39053905

39063906
void CGDebugInfo::EmitFuncDeclForCallSite(llvm::CallBase *CallOrInvoke,

clang/test/CodeGen/debug-info-extern-call.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
// When entry values are emitted, expect a subprogram for extern decls so that
22
// the dwarf generator can describe call site parameters at extern call sites.
33
//
4+
// Initial implementation relied on the 'retainedTypes:' from the corresponding
5+
// DICompileUnit, so we also ensure that we do not store the extern declaration
6+
// subprogram into the 'retainedTypes:'.
7+
//
48
// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -S -emit-llvm %s -o - \
59
// RUN: | FileCheck %s -check-prefix=DECLS-FOR-EXTERN
610

@@ -17,6 +21,8 @@
1721
// RUN: %clang -g -O2 -target x86_64-none-linux-gnu -gsce -S -emit-llvm %s -o - \
1822
// RUN: | FileCheck %s -check-prefix=NO-DECLS-FOR-EXTERN
1923

24+
// DECLS-FOR-EXTERN-NOT: !DICompileUnit({{.*}}retainedTypes: ![[RETTYPES:[0-9]+]]
25+
// DECLS-FOR-EXTERN-NOT: ![[RETTYPES]] = !{
2026
// DECLS-FOR-EXTERN: !DISubprogram(name: "fn1"
2127
// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "memcmp"
2228
// DECLS-FOR-EXTERN-NOT: !DISubprogram(name: "__some_reserved_name"

clang/test/Modules/DebugInfoTransitiveImport.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212

1313
// Definition of left:
1414
// CHECK: !DICompileUnit({{.*}}dwoId:
15-
// CHECK: ![[LEFT:[0-9]+]] = !DIFile({{.*}}diamond_left.h
1615
// CHECK: !DIImportedEntity(tag: DW_TAG_imported_declaration,
17-
// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[LEFT]], line: 3)
16+
// CHECK-SAME: entity: ![[MODULE:.*]], file: ![[LEFT:.*]], line: 3)
1817
// CHECK: ![[MODULE]] = !DIModule(scope: null, name: "diamond_top"
18+
// CHECK: ![[LEFT]] = !DIFile({{.*}}diamond_left.h
1919

2020
// Skeleton for top:
2121
// CHECK: !DICompileUnit({{.*}}splitDebugFilename: {{.*}}diamond_top{{.*}}dwoId:

clang/test/Modules/ModuleDebugInfo.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,6 @@
5151
// CHECK-SAME: )
5252
// CHECK: !DIEnumerator(name: "e5", value: 5, isUnsigned: true)
5353

54-
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
55-
// no mangled name here yet.
56-
57-
// This type is anchored by a function parameter.
58-
// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
59-
// CHECK-SAME: elements:
60-
// CHECK-SAME: templateParams:
61-
// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
62-
6354
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Struct"
6455
// CHECK-SAME: identifier: "_ZTSN8DebugCXX6StructE")
6556

@@ -85,6 +76,12 @@
8576
// CHECK-SAME: templateParams:
8677
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIlNS_6traitsIlEEEE")
8778

79+
// This type is anchored by a function parameter.
80+
// CHECK: !DICompositeType(tag: DW_TAG_class_type, name: "A<void>"
81+
// CHECK-SAME: elements:
82+
// CHECK-SAME: templateParams:
83+
// CHECK-SAME: identifier: "_ZTSN8DebugCXX1AIJvEEE")
84+
8885
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "FloatInstantiation"
8986
// no mangled name here yet.
9087

@@ -93,6 +90,9 @@
9390
// CHECK-SAME: flags: DIFlagFwdDecl
9491
// CHECK-SAME: identifier: "_ZTSN8DebugCXX8TemplateIfNS_6traitsIfEEEE")
9592

93+
// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "B",
94+
// no mangled name here yet.
95+
9696
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "Virtual"
9797
// CHECK-SAME: elements:
9898
// CHECK-SAME: identifier: "_ZTS7Virtual")

clang/test/Modules/ModuleDebugInfo.m

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,13 @@
3636
// CHECK-NOT: name:
3737
// CHECK-SAME: elements:
3838

39-
// CHECK: !DISubprogram(name: "+[ObjCClass classMethod]",
40-
// CHECK-SAME: scope: ![[MODULE]],
39+
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
40+
// CHECK-SAME: scope: ![[MODULE]],
4141

4242
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
4343
// CHECK-SAME: scope: ![[MODULE]],
4444
// CHECK-SAME: elements
4545

46-
// The forward declaration should not be in the module scope.
47-
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "OpaqueData", file
48-
49-
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
50-
// CHECK-SAME: scope: ![[MODULE]],
51-
5246
// CHECK: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClassWithPrivateIVars",
5347
// CHECK-SAME: scope: ![[MODULE]],
5448
// CHECK-SAME: elements
@@ -85,11 +79,8 @@
8579
// The output order is sublty different for module vs. pch,
8680
// so these are checked separately:
8781
//
88-
// CHECK2: !DISubprogram(name: "+[ObjCClass classMethod]"
89-
// CHECK2: !DISubprogram(name: "-[ObjCClass instanceMethodWithInt:]"
82+
// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
9083
// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "ObjCClass",
9184
// CHECK2: !DIObjCProperty(name: "property",
9285
// CHECK2: !DIDerivedType(tag: DW_TAG_member, name: "ivar"
93-
// CHECK2: !DISubprogram(name: "-[Category(Category) categoryMethod]"
94-
// CHECK2: !DICompositeType(tag: DW_TAG_structure_type, name: "FwdDecl",
9586
// CHECK2: !DIDerivedType(tag: DW_TAG_typedef, name: "InnerEnum"

0 commit comments

Comments
 (0)