Skip to content

Commit 6b30623

Browse files
committed
DebugInfo: Make the simplified template names prefix more unique
1 parent 2232d35 commit 6b30623

File tree

8 files changed

+250
-250
lines changed

8 files changed

+250
-250
lines changed

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5199,7 +5199,7 @@ std::string CGDebugInfo::GetName(const Decl *D, bool Qualified) const {
51995199
TemplateNamesKind == codegenoptions::DebugTemplateNamesKind::Mangled;
52005200
// check if it's a template
52015201
if (Mangled)
5202-
OS << "_STN";
5202+
OS << "_STN|";
52035203

52045204
OS << ND->getDeclName();
52055205
std::string EncodedOriginalName;

clang/test/CodeGenCXX/debug-info-simple-template-names.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,20 @@ t4 v1;
3535
void f() {
3636
// Basic examples of simplifiable/rebuildable names
3737
f1<>();
38-
// CHECK: !DISubprogram(name: "_STNf1|<>",
38+
// CHECK: !DISubprogram(name: "_STN|f1|<>",
3939
// SIMPLE: !DISubprogram(name: "f1",
4040
// FULL: !DISubprogram(name: "f1<>",
4141
f1<int>();
42-
// CHECK: !DISubprogram(name: "_STNf1|<int>",
42+
// CHECK: !DISubprogram(name: "_STN|f1|<int>",
4343
f1<void()>();
44-
// CHECK: !DISubprogram(name: "_STNf1|<void ()>",
44+
// CHECK: !DISubprogram(name: "_STN|f1|<void ()>",
4545
f2<int, 42>();
46-
// CHECK: !DISubprogram(name: "_STNf2|<int, 42>",
46+
// CHECK: !DISubprogram(name: "_STN|f2|<int, 42>",
4747

4848
// Check that even though the nested name can't be rebuilt, it'll carry its
4949
// full name and the outer name can be rebuilt from that.
5050
f1<t1<void() noexcept>>();
51-
// CHECK: !DISubprogram(name: "_STNf1|<t1<void () noexcept> >",
51+
// CHECK: !DISubprogram(name: "_STN|f1|<t1<void () noexcept> >",
5252

5353
// Vector array types are encoded in DWARF but the decoding in llvm-dwarfdump
5454
// isn't implemented yet.
@@ -109,7 +109,7 @@ void f() {
109109
// worry about seeing conversion operators as parameters to other templates.
110110

111111
f3<t1>();
112-
// CHECK: !DISubprogram(name: "_STNf3|<t1>",
112+
// CHECK: !DISubprogram(name: "_STN|f3|<t1>",
113113

114114
f1<_BitInt(3)>();
115115
// CHECK: !DISubprogram(name: "f1<_BitInt(3)>",

llvm/lib/Bitcode/Reader/MetadataLoader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1509,7 +1509,7 @@ Error MetadataLoader::MetadataLoaderImpl::parseOneMetadata(
15091509
// DICompositeType flag specifying whether template parameters are
15101510
// required on declarations of this type.
15111511
StringRef NameStr = Name->getString();
1512-
if (!NameStr.contains('<') || NameStr.startswith("_STN"))
1512+
if (!NameStr.contains('<') || NameStr.startswith("_STN|"))
15131513
TemplateParams = getMDOrNull(Record[14]);
15141514
}
15151515
} else {

llvm/lib/DebugInfo/DWARF/DWARFDie.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ struct DWARFTypePrinter {
291291
}
292292
Word = true;
293293
StringRef Name = NamePtr;
294-
static constexpr StringRef MangledPrefix = "_STN";
294+
static constexpr StringRef MangledPrefix = "_STN|";
295295
if (Name.startswith(MangledPrefix)) {
296296
Name = Name.drop_front(MangledPrefix.size());
297297
auto Separator = Name.find('|');

llvm/test/DebugInfo/X86/tu-to-non-tu.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@
6666
; };
6767
; ref_templ_non_tu_simple v3;
6868
;
69-
; // Modify templ_non_tu<bool>'s name to be mangled ('_STN' name '|' args)
69+
; // Modify templ_non_tu<bool>'s name to be mangled ('_STN|' name '|' args)
7070
; template <>
7171
; struct templ_non_tu<bool> {
7272
; virtual void f1();
@@ -117,7 +117,7 @@
117117
; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu"
118118
; CHECK: DW_TAG_structure_type
119119
; CHECK-NOT: DW_TAG
120-
; CHECK: DW_AT_name {{.*}}"_STNtempl_non_tu|<int>"
120+
; CHECK: DW_AT_name {{.*}}"_STN|templ_non_tu|<int>"
121121

122122
; CHECK: DW_TAG_structure_type
123123
; CHECK-NOT: DW_TAG
@@ -134,7 +134,7 @@
134134
; CHECK: DW_AT_name {{.*}}"ref_templ_non_tu_mangled"
135135
; CHECK: DW_TAG_structure_type
136136
; CHECK-NOT: DW_TAG
137-
; CHECK: DW_AT_name ("_STNtempl_non_tu|<bool>")
137+
; CHECK: DW_AT_name ("_STN|templ_non_tu|<bool>")
138138
; CHECK-NOT: DW_TAG
139139
; CHECK: DW_TAG_template_type_parameter
140140
; CHECK-NEXT: DW_AT_type {{.*}}"bool"
@@ -244,7 +244,7 @@ attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
244244
!15 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ref_templ_non_tu", file: !3, line: 30, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !16, identifier: "_ZTS16ref_templ_non_tu")
245245
!16 = !{!17}
246246
!17 = !DIDerivedType(tag: DW_TAG_member, name: "v1", scope: !15, file: !3, line: 31, baseType: !18, size: 64)
247-
!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STNtempl_non_tu|<int>", file: !3, line: 26, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !19, vtableHolder: !18, templateParams: !30)
247+
!18 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|templ_non_tu|<int>", file: !3, line: 26, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !19, vtableHolder: !18, templateParams: !30)
248248
!19 = !{!20, !26}
249249
!20 = !DIDerivedType(tag: DW_TAG_member, name: "_vptr$templ_non_tu", scope: !3, file: !3, baseType: !21, size: 64, flags: DIFlagArtificial)
250250
!21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !22, size: 64)
@@ -277,7 +277,7 @@ attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
277277
!48 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "ref_templ_non_tu_mangled", file: !3, line: 53, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !49, identifier: "_ZTS24ref_templ_non_tu_mangled")
278278
!49 = !{!50}
279279
!50 = !DIDerivedType(tag: DW_TAG_member, name: "v1", scope: !48, file: !3, line: 54, baseType: !51, size: 64)
280-
!51 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STNtempl_non_tu|<bool>", file: !3, line: 49, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !52, vtableHolder: !51, templateParams: !57)
280+
!51 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|templ_non_tu|<bool>", file: !3, line: 49, size: 64, flags: DIFlagTypePassByReference | DIFlagNonTrivial, elements: !52, vtableHolder: !51, templateParams: !57)
281281
!52 = !{!20, !53}
282282
!53 = !DISubprogram(name: "f1", linkageName: "_ZN12templ_non_tuIbE2f1Ev", scope: !51, file: !3, line: 50, type: !54, scopeLine: 50, containingType: !51, virtualIndex: 0, flags: DIFlagPrototyped, spFlags: DISPFlagVirtual)
283283
!54 = !DISubroutineType(types: !55)

llvm/test/ThinLTO/X86/debuginfo-compositetype-import.ll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
; CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, size: 128, flags: DIFlagFwdDecl, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified")
1919
; CHECK: distinct !DICompositeType(tag: DW_TAG_union_type, file: !{{[0-9]+}}, line: 115, size: 384, flags: DIFlagFwdDecl, identifier: "union")
2020
; CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, size: 128, flags: DIFlagFwdDecl, identifier: "struct_templ")
21-
; CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STNstruct|<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, size: 128, flags: DIFlagFwdDecl, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified_mangled")
21+
; CHECK: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|struct|<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, size: 128, flags: DIFlagFwdDecl, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified_mangled")
2222

2323
; Ensure that full type definitions of composite types are imported if requested
2424
; RUN: llvm-lto -import-full-type-definitions -thinlto-action=import %t2.bc -thinlto-index=%t.index.bc -o - | llvm-dis -o - | FileCheck %s --check-prefix=FULL
@@ -34,7 +34,7 @@
3434
; FULL: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, baseType: !{{[0-9]+}}, size: 128, offset: 64, elements: !{{[0-9]+}}, vtableHolder: !{{[0-9]+}}, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified")
3535
; FULL: distinct !DICompositeType(tag: DW_TAG_union_type, file: !{{[0-9]+}}, line: 115, size: 384, elements: !{{[0-9]+}}, identifier: "union")
3636
; FULL: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, baseType: !{{[0-9]+}}, size: 128, offset: 64, elements: !{{[0-9]+}}, vtableHolder: !{{[0-9]+}}, templateParams: !{{[0-9]+}}, identifier: "struct_templ")
37-
; FULL: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STNstruct|<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, baseType: !{{[0-9]+}}, size: 128, offset: 64, elements: !{{[0-9]+}}, vtableHolder: !{{[0-9]+}}, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified_mangled")
37+
; FULL: distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|struct|<>", scope: !{{[0-9]+}}, file: !{{[0-9]+}}, line: 309, baseType: !{{[0-9]+}}, size: 128, offset: 64, elements: !{{[0-9]+}}, vtableHolder: !{{[0-9]+}}, templateParams: !{{[0-9]+}}, identifier: "struct_templ_simplified_mangled")
3838

3939
; ModuleID = 'debuginfo-compositetype-import.c'
4040
source_filename = "debuginfo-compositetype-import.c"
@@ -65,4 +65,4 @@ entry:
6565
!11 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct", scope: !1, file: !1, line: 309, baseType: !10, size: 128, offset: 64, elements: !5, vtableHolder: !10, templateParams: !5, identifier: "struct_templ_simplified")
6666
!12 = distinct !DICompositeType(tag: DW_TAG_union_type, file: !1, line: 115, size: 384, elements: !5, identifier: "union")
6767
!13 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "struct<>", scope: !1, file: !1, line: 309, baseType: !10, size: 128, offset: 64, elements: !5, vtableHolder: !10, templateParams: !5, identifier: "struct_templ")
68-
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STNstruct|<>", scope: !1, file: !1, line: 309, baseType: !10, size: 128, offset: 64, elements: !5, vtableHolder: !10, templateParams: !5, identifier: "struct_templ_simplified_mangled")
68+
!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "_STN|struct|<>", scope: !1, file: !1, line: 309, baseType: !10, size: 128, offset: 64, elements: !5, vtableHolder: !10, templateParams: !5, identifier: "struct_templ_simplified_mangled")

llvm/test/tools/llvm-dwarfdump/X86/simplified-template-names-fail.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ v1:
135135
.Linfo_string5:
136136
.asciz "T" # string offset=162
137137
.Linfo_string6:
138-
.asciz "_STNt1|<it>" # string offset=164
138+
.asciz "_STN|t1|<it>" # string offset=164
139139
.ident "clang version 14.0.0 ([email protected]:llvm/llvm-project.git 9daec0955132e6e33b086edc63c6f3e0f5712323)"
140140
.section ".note.GNU-stack","",@progbits
141141
.addrsig

0 commit comments

Comments
 (0)