llvm.org GIT mirror llvm / 20f2420
Use fully qualified name when printing S_CONSTANT records Summary: Before it was using the fully qualified name only for static data members. Now it does for all variable names to match MSVC. Reviewers: rnk Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D63012 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@363335 91177308-0d34-0410-b5e6-96231b3b80d8 Amy Huang 3 months ago
2 changed file(s) with 99 addition(s) and 60 deletion(s). Raw diff Collapse all Expand all
30683068 OS.EmitBinaryData(SRef);
30693069
30703070 OS.AddComment("Name");
3071 // Get fully qualified name if global is a static data member.
3072 std::string Name = DIGV->getDisplayName();
3071 const DIScope *Scope = DIGV->getScope();
3072 // For static data members, get the scope from the declaration.
30733073 if (const auto *MemberDecl = dyn_cast_or_null(
30743074 DIGV->getRawStaticDataMemberDeclaration()))
3075 Name = getFullyQualifiedName(MemberDecl->getScope(), Name);
3076 emitNullTerminatedSymbolName(OS, Name);
3075 Scope = MemberDecl->getScope();
3076 emitNullTerminatedSymbolName(OS,
3077 getFullyQualifiedName(Scope, DIGV->getName()));
30773078 endSymbolRecord(SConstantEnd);
30783079 }
30793080 }
11 ; RUN: llc < %s -filetype=obj | llvm-readobj - --codeview | FileCheck %s --check-prefix=OBJ
22
33 ; C++ source to regenerate:
4 ; namespace Test1 {
45 ; const float TestConst1 = 3.14;
6 ; }
57 ; struct S {
68 ; static const int TestConst2 = -10;
9 ; enum { SEnum = 42 };
710 ; }
811 ; enum TestEnum : int {
912 ; ENUM_A = 2147000000,
1114 ; };
1215 ; void useConst(int);
1316 ; void foo() {
14 ; useConst(TestConst1);
17 ; useConst(Test1::TestConst1);
1518 ; useConst(S::TestConst2);
1619 ; useConst(ENUM_B);
20 ; useConst(S::SEnum);
1721 ; }
1822 ; $ clang t.cpp -S -emit-llvm -g -gcodeview -o t.ll
1923
2024 ; ASM-LABEL: .long 241 # Symbol subsection for globals
2125 ; ASM: .short {{.*-.*}} # Record length
2226 ; ASM: .short 4359 # Record kind: S_CONSTANT
23 ; ASM-NEXT: .long 4099 # Type
27 ; ASM-NEXT: .long 4102 # Type
2428 ; ASM-NEXT: .byte 0x04, 0x80, 0xc3, 0xf5 # Value
2529 ; ASM-NEXT: .byte 0x48, 0x40
26 ; ASM-NEXT: .asciz "TestConst1" # Name
30 ; ASM-NEXT: .asciz "Test1::TestConst1" # Name
2731 ; ASM: .short {{.*-.*}} # Record length
2832 ; ASM: .short 4359 # Record kind: S_CONSTANT
29 ; ASM-NEXT: .long 4100 # Type
33 ; ASM-NEXT: .long 4103 # Type
3034 ; ASM-NEXT: .byte 0x61, 0x00 # Value
3135 ; ASM-NEXT: .asciz "S::TestConst2" # Name
3236 ; ASM: .short {{.*-.*}} # Record length
3337 ; ASM: .short 4359 # Record kind: S_CONSTANT
34 ; ASM-NEXT: .long 4102 # Type
38 ; ASM-NEXT: .long 4105 # Type
3539 ; ASM-NEXT: .byte 0x0a, 0x80, 0x40, 0x61 # Value
3640 ; ASM-NEXT: .byte 0x07, 0x80, 0xff, 0xff
3741 ; ASM-NEXT: .byte 0xff, 0xff
3842 ; ASM-NEXT: .asciz "ENUM_B" # Name
43 ; ASM-NOT: .asciz "S::SEnum" # Name
3944
4045 ; OBJ: CodeViewDebugInfo [
4146 ; OBJ: Section: .debug$S
4449 ; OBJ: SubSectionType: Symbols (0xF1)
4550 ; OBJ: ConstantSym {
4651 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
47 ; OBJ-NEXT: Type: const float (0x1003)
52 ; OBJ-NEXT: Type: const float (0x1006)
4853 ; OBJ-NEXT: Value: 1078523331
49 ; OBJ-NEXT: Name: TestConst1
54 ; OBJ-NEXT: Name: Test1::TestConst1
5055 ; OBJ-NEXT: }
5156 ; OBJ-NEXT: ConstantSym {
5257 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
53 ; OBJ-NEXT: Type: const char (0x1004)
58 ; OBJ-NEXT: Type: const char (0x1007)
5459 ; OBJ-NEXT: Value: 97
5560 ; OBJ-NEXT: Name: S::TestConst2
5661 ; OBJ-NEXT: }
5762 ; OBJ-NEXT: ConstantSym {
5863 ; OBJ-NEXT: Kind: S_CONSTANT (0x1107)
59 ; OBJ-NEXT: Type: TestEnum (0x1006)
64 ; OBJ-NEXT: Type: TestEnum (0x1009)
6065 ; OBJ-NEXT: Value: 18446744071562551616
6166 ; OBJ-NEXT: Name: ENUM_B
6267 ; OBJ-NEXT: }
63
68 ; OBJ-NOT: Name: S::SEnum
6469
6570 ; ModuleID = 't.cpp'
6671 source_filename = "t.cpp"
6772 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
68 target triple = "x86_64-w64-windows-gnu"
73 target triple = "x86_64-pc-windows-msvc19.16.27030"
6974
70 ; Function Attrs: noinline nounwind optnone
71 define dso_local void @_Z3foov() #0 !dbg !28 {
75 ; Function Attrs: noinline nounwind optnone uwtable
76 define dso_local void @"?useConst@@YAXH@Z"(i32) #0 !dbg !32 {
7277 entry:
73 call void @_Z8useConsti(i32 3), !dbg !32
74 call void @_Z8useConsti(i32 97), !dbg !33
75 call void @_Z8useConsti(i32 -2147000000), !dbg !34
76 ret void, !dbg !35
78 %.addr = alloca i32, align 4
79 store i32 %0, i32* %.addr, align 4
80 call void @llvm.dbg.declare(metadata i32* %.addr, metadata !36, metadata !DIExpression()), !dbg !37
81 ret void, !dbg !37
7782 }
7883
79 declare dso_local void @_Z8useConsti(i32) #1
84 ; Function Attrs: nounwind readnone speculatable
85 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
86
87 ; Function Attrs: noinline norecurse nounwind optnone uwtable
88 define dso_local i32 @main() #2 !dbg !38 {
89 entry:
90 %retval = alloca i32, align 4
91 store i32 0, i32* %retval, align 4
92 call void @"?useConst@@YAXH@Z"(i32 3), !dbg !41
93 call void @"?useConst@@YAXH@Z"(i32 97), !dbg !42
94 call void @"?useConst@@YAXH@Z"(i32 -2147000000), !dbg !43
95 call void @"?useConst@@YAXH@Z"(i32 42), !dbg !44
96 call void @llvm.debugtrap(), !dbg !45
97 ret i32 0, !dbg !46
98 }
99
100 ; Function Attrs: nounwind
101 declare void @llvm.debugtrap() #3
102
103 attributes #0 = { noinline nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
104 attributes #1 = { nounwind readnone speculatable }
105 attributes #2 = { noinline norecurse nounwind optnone uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
106 attributes #3 = { nounwind }
80107
81108 !llvm.dbg.cu = !{!0}
82 !llvm.module.flags = !{!24, !25, !26}
83 !llvm.ident = !{!27}
109 !llvm.module.flags = !{!27, !28, !29, !30}
110 !llvm.ident = !{!31}
84111
85 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git dee1891507401f396290b5d9cb5717d6b0755337)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !9, globals: !15, nameTableKind: None)
86 !1 = !DIFile(filename: "", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "6d700c7d582557a012214ac1f1f8721b")
87 !2 = !{!3}
88 !3 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "TestEnum", file: !4, line: 5, baseType: !5, size: 32, elements: !6, identifier: "_ZTS8TestEnum")
89 !4 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctest", checksumkind: CSK_MD5, checksum: "6d700c7d582557a012214ac1f1f8721b")
90 !5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
91 !6 = !{!7, !8}
92 !7 = !DIEnumerator(name: "ENUM_A", value: 2147000000)
93 !8 = !DIEnumerator(name: "ENUM_B", value: -2147000000)
94 !9 = !{!10}
95 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !4, line: 2, size: 8, flags: DIFlagTypePassByValue, elements: !11, identifier: "_ZTS1S")
96 !11 = !{!12}
97 !12 = !DIDerivedType(tag: DW_TAG_member, name: "TestConst2", scope: !10, file: !4, line: 3, baseType: !13, flags: DIFlagStaticMember, extraData: i8 97)
98 !13 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !14)
99 !14 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
100 !15 = !{!16, !20, !22}
101 !16 = !DIGlobalVariableExpression(var: !17, expr: !DIExpression(DW_OP_constu, 1078523331, DW_OP_stack_value))
102 !17 = distinct !DIGlobalVariable(name: "TestConst1", scope: !0, file: !4, line: 1, type: !18, isLocal: true, isDefinition: true)
103 !18 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !19)
104 !19 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
105 !20 = !DIGlobalVariableExpression(var: !21, expr: !DIExpression(DW_OP_constu, 97, DW_OP_stack_value))
106 !21 = distinct !DIGlobalVariable(name: "TestConst2", scope: !0, file: !4, line: 3, type: !13, isLocal: true, isDefinition: true, declaration: !12)
107 !22 = !DIGlobalVariableExpression(var: !23, expr: !DIExpression(DW_OP_constu, 18446744071562551616, DW_OP_stack_value))
108 !23 = distinct !DIGlobalVariable(name: "ENUM_B", scope: !0, file: !4, line: 7, type: !3, isLocal: true, isDefinition: true)
109 !24 = !{i32 2, !"CodeView", i32 1}
110 !25 = !{i32 2, !"Debug Info Version", i32 3}
111 !26 = !{i32 1, !"wchar_size", i32 2}
112 !27 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git dee1891507401f396290b5d9cb5717d6b0755337)"}
113 !28 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !4, file: !4, line: 10, type: !29, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !31)
114 !29 = !DISubroutineType(types: !30)
115 !30 = !{null}
116 !31 = !{}
117 !32 = !DILocation(line: 11, scope: !28)
118 !33 = !DILocation(line: 12, scope: !28)
119 !34 = !DILocation(line: 13, scope: !28)
120 !35 = !DILocation(line: 14, scope: !28)
112 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 9.0.0 (https://github.com/llvm/llvm-project.git f60f863075c7056f26e701b0405fc5752f0db576)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !16, globals: !17, nameTableKind: None)
113 !1 = !DIFile(filename: "t.cpp", directory: "C:\5Csrc\5Ctesting", checksumkind: CSK_MD5, checksum: "70da26ef1009521e2127bf71f8d532a2")
114 !2 = !{!3, !12}
115 !3 = !DICompositeType(tag: DW_TAG_enumeration_type, scope: !4, file: !1, line: 6, baseType: !9, size: 32, elements: !10, identifier: ".?AW4@S@@")
116 !4 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !1, line: 4, size: 8, flags: DIFlagTypePassByValue, elements: !5, identifier: ".?AUS@@")
117 !5 = !{!6, !3}
118 !6 = !DIDerivedType(tag: DW_TAG_member, name: "TestConst2", scope: !4, file: !1, line: 5, baseType: !7, flags: DIFlagStaticMember, extraData: i8 97)
119 !7 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !8)
120 !8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
121 !9 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
122 !10 = !{!11}
123 !11 = !DIEnumerator(name: "SEnum", value: 42)
124 !12 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "TestEnum", file: !1, line: 8, baseType: !9, size: 32, elements: !13, identifier: ".?AW4TestEnum@@")
125 !13 = !{!14, !15}
126 !14 = !DIEnumerator(name: "ENUM_A", value: 2147000000)
127 !15 = !DIEnumerator(name: "ENUM_B", value: -2147000000)
128 !16 = !{!4}
129 !17 = !{!18, !23, !25}
130 !18 = !DIGlobalVariableExpression(var: !19, expr: !DIExpression(DW_OP_constu, 1078523331, DW_OP_stack_value))
131 !19 = distinct !DIGlobalVariable(name: "TestConst1", scope: !20, file: !1, line: 2, type: !21, isLocal: true, isDefinition: true)
132 !20 = !DINamespace(name: "Test1", scope: null)
133 !21 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !22)
134 !22 = !DIBasicType(name: "float", size: 32, encoding: DW_ATE_float)
135 !23 = !DIGlobalVariableExpression(var: !24, expr: !DIExpression(DW_OP_constu, 97, DW_OP_stack_value))
136 !24 = distinct !DIGlobalVariable(name: "TestConst2", scope: !0, file: !1, line: 5, type: !7, isLocal: true, isDefinition: true, declaration: !6)
137 !25 = !DIGlobalVariableExpression(var: !26, expr: !DIExpression(DW_OP_constu, 18446744071562551616, DW_OP_stack_value))
138 !26 = distinct !DIGlobalVariable(name: "ENUM_B", scope: !0, file: !1, line: 10, type: !12, isLocal: true, isDefinition: true)
139 !27 = !{i32 2, !"CodeView", i32 1}
140 !28 = !{i32 2, !"Debug Info Version", i32 3}
141 !29 = !{i32 1, !"wchar_size", i32 2}
142 !30 = !{i32 7, !"PIC Level", i32 2}
143 !31 = !{!"clang version 9.0.0 (https://github.com/llvm/llvm-project.git f60f863075c7056f26e701b0405fc5752f0db576)"}
144 !32 = distinct !DISubprogram(name: "useConst", linkageName: "?useConst@@YAXH@Z", scope: !1, file: !1, line: 12, type: !33, scopeLine: 12, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !35)
145 !33 = !DISubroutineType(types: !34)
146 !34 = !{null, !9}
147 !35 = !{}
148 !36 = !DILocalVariable(arg: 1, scope: !32, file: !1, line: 12, type: !9)
149 !37 = !DILocation(line: 12, scope: !32)
150 !38 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 13, type: !39, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !35)
151 !39 = !DISubroutineType(types: !40)
152 !40 = !{!9}
153 !41 = !DILocation(line: 14, scope: !38)
154 !42 = !DILocation(line: 15, scope: !38)
155 !43 = !DILocation(line: 16, scope: !38)
156 !44 = !DILocation(line: 17, scope: !38)
157 !45 = !DILocation(line: 18, scope: !38)
158 !46 = !DILocation(line: 19, scope: !38)