llvm.org GIT mirror llvm / bbf32bd
Make DW_AT_[MIPS_]linkage_name optional, and off by default for SCE. Mangled "linkage" names can be huge, and if the debugger (or other tools) have no use for them, the size savings can be very impressive (on the order of 40%). Add one test for controlling behavior, and modify a number of tests to either stop using linkage names, or make llc emit them (so these tests will still run when the default triple is for PS4). Differential Revision: http://reviews.llvm.org/D11374 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244678 91177308-0d34-0410-b5e6-96231b3b80d8 Paul Robinson 5 years ago
17 changed file(s) with 116 addition(s) and 25 deletion(s). Raw diff Collapse all Expand all
115115 clEnumVal(Disable, "Disabled"), clEnumValEnd),
116116 cl::init(Default));
117117
118 static cl::opt
119 DwarfLinkageNames("dwarf-linkage-names", cl::Hidden,
120 cl::desc("Emit DWARF linkage-name attributes."),
121 cl::values(clEnumVal(Default, "Default for platform"),
122 clEnumVal(Enable, "Enabled"),
123 clEnumVal(Disable, "Disabled"), clEnumValEnd),
124 cl::init(Default));
125
118126 static const char *const DWARFGroupName = "DWARF Emission";
119127 static const char *const DbgTimerName = "DWARF Debug Writer";
120128
248256 HasDwarfPubSections = tuneForGDB();
249257 else
250258 HasDwarfPubSections = DwarfPubSections == Enable;
259
260 // SCE does not use linkage names.
261 if (DwarfLinkageNames == Default)
262 UseLinkageNames = !tuneForSCE();
263 else
264 UseLinkageNames = DwarfLinkageNames == Enable;
251265
252266 unsigned DwarfVersionNumber = Asm->TM.Options.MCOptions.DwarfVersion;
253267 DwarfVersion = DwarfVersionNumber ? DwarfVersionNumber
332332 /// Whether to use the GNU TLS opcode (instead of the standard opcode).
333333 bool UseGNUTLSOpcode;
334334
335 /// Whether to emit DW_AT_[MIPS_]linkage_name.
336 bool UseLinkageNames;
337
335338 /// Version of dwarf we're emitting.
336339 unsigned DwarfVersion;
337340
587590 SymSize[Sym] = Size;
588591 }
589592
593 /// Returns whether to emit DW_AT_[MIPS_]linkage_name.
594 bool useLinkageNames() const { return UseLinkageNames; }
595
590596 /// Returns whether to use DW_OP_GNU_push_tls_address, instead of the
591597 /// standard DW_OP_form_tls_address opcode
592598 bool useGNUTLSOpcode() const { return UseGNUTLSOpcode; }
666666 }
667667
668668 void DwarfUnit::addLinkageName(DIE &Die, StringRef LinkageName) {
669 if (!LinkageName.empty())
669 if (!LinkageName.empty() && DD->useLinkageNames())
670670 addString(Die,
671671 DD->getDwarfVersion() >= 4 ? dwarf::DW_AT_linkage_name
672672 : dwarf::DW_AT_MIPS_linkage_name,
1212 ; CHECK-NOT: DW_TAG
1313 ; CHECK: DW_AT_low_pc
1414 ; CHECK-NOT: DW_TAG
15 ; CHECK: DW_AT_linkage_name {{.*}} "_ZZN1B2fnEvEN1A3fooEv"
15 ; CHECK: DW_AT_name {{.*}} "foo"
1616 ; And just double check that there's no out of line definition that references
1717 ; this subprogram.
1818 ; CHECK-NOT: DW_AT_specification {{.*}} {[[FOO_INL]]}
22 ; For some reason, the output when targetting sparc is not quite as expected.
33 ; XFAIL: sparc
44
5 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
5 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=Enable < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
66
77 ; IR generated from clang -O0 with:
88 ; struct C {
0 ; DWARF linkage name attributes are optional; verify they are missing for
1 ; PS4 triple or when tuning for SCE.
2
3 ; RUN: llc -O0 -mtriple=x86_64-unknown-unknown < %s | FileCheck %s -check-prefix LINKAGE1
4 ; RUN: llc -O0 -mtriple=x86_64-unknown-unknown < %s | FileCheck %s -check-prefix LINKAGE2
5 ; RUN: llc -O0 -mtriple=x86_64-scei-ps4 < %s | FileCheck %s -check-prefix NOLINKAGE
6 ; RUN: llc -O0 -mtriple=x86_64-unknown-unknown -debugger-tune=sce < %s | FileCheck %s -check-prefix NOLINKAGE
7
8 ; $ clang++ -emit-llvm -S -g dwarf-linkage-names.cpp
9 ; namespace test {
10 ; int global_var;
11 ; int bar() { return global_var; }
12 ;};
13
14 ; With linkage names, we get an attribute for the declaration (first) entry
15 ; for the global variable, and one for the function.
16
17 ; This assumes the variable will appear before the function.
18 ; LINKAGE1: .section .debug_info
19 ; LINKAGE1: DW_TAG_variable
20 ; LINKAGE1-NOT: DW_TAG
21 ; LINKAGE1: {{DW_AT_(MIPS_)*linkage_name}}
22 ; LINKAGE1: DW_TAG_subprogram
23 ; LINKAGE1-NOT: DW_TAG
24 ; LINKAGE1: {{DW_AT_(MIPS_)*linkage_name}}
25 ; LINKAGE1: .section
26
27 ; Also verify we see the mangled names. We do this as a separate pass to
28 ; avoid depending on the order of .debug_info and .debug_str sections.
29
30 ; LINKAGE2-DAG: .asciz "_ZN4test10global_varE"
31 ; LINKAGE2-DAG: .asciz "_ZN4test3barEv"
32
33 ; Without linkage names, verify there aren't any linkage-name attributes,
34 ; and no mangled names.
35
36 ; NOLINKAGE-NOT: {{DW_AT_(MIPS_)*linkage_name}}
37 ; NOLINKAGE-NOT: .asciz "_ZN4test10global_varE"
38 ; NOLINKAGE-NOT: .asciz "_ZN4test3barEv"
39
40 @_ZN4test10global_varE = global i32 0, align 4
41
42 ; Function Attrs: nounwind uwtable
43 define i32 @_ZN4test3barEv() #0 {
44 entry:
45 %0 = load i32, i32* @_ZN4test10global_varE, align 4, !dbg !14
46 ret i32 %0, !dbg !15
47 }
48
49 attributes #0 = { nounwind uwtable "disable-tail-calls"="false" "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+sse,+sse2" "unsafe-fp-math"="false" "use-soft-float"="false" }
50
51 !llvm.dbg.cu = !{!0}
52 !llvm.module.flags = !{!11, !12}
53 !llvm.ident = !{!13}
54
55 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 3.8.0 (trunk 244662)", isOptimized: false, runtimeVersion: 0, emissionKind: 1, enums: !2, subprograms: !3, globals: !9)
56 !1 = !DIFile(filename: "dwarf-linkage-names.cpp", directory: "/home/probinson/projects/scratch")
57 !2 = !{}
58 !3 = !{!4}
59 !4 = !DISubprogram(name: "bar", linkageName: "_ZN4test3barEv", scope: !5, file: !1, line: 3, type: !6, isLocal: false, isDefinition: true, scopeLine: 3, flags: DIFlagPrototyped, isOptimized: false, function: i32 ()* @_ZN4test3barEv, variables: !2)
60 !5 = !DINamespace(name: "test", scope: null, file: !1, line: 1)
61 !6 = !DISubroutineType(types: !7)
62 !7 = !{!8}
63 !8 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
64 !9 = !{!10}
65 !10 = !DIGlobalVariable(name: "global_var", linkageName: "_ZN4test10global_varE", scope: !5, file: !1, line: 2, type: !8, isLocal: false, isDefinition: true, variable: i32* @_ZN4test10global_varE)
66 !11 = !{i32 2, !"Dwarf Version", i32 4}
67 !12 = !{i32 2, !"Debug Info Version", i32 3}
68 !13 = !{!"clang version 3.8.0 (trunk 244662)"}
69 !14 = !DILocation(line: 3, column: 21, scope: !4)
70 !15 = !DILocation(line: 3, column: 14, scope: !4)
3737 ; CHECK-NOT: {{DW_TAG|NULL}}
3838 ; CHECK: DW_TAG_member
3939 ; CHECK-NOT: {{DW_TAG|NULL}}
40 ; CHECK: DW_TAG_subprogram
40 ; CHECK: [[M_FN2_DECL:.*]]: DW_TAG_subprogram
4141 ; CHECK-NOT: DW_TAG
4242 ; CHECK: DW_AT_name {{.*}} "m_fn2"
4343 ; CHECK-NOT: {{DW_TAG|NULL}}
44 ; CHECK: [[M_FN2_THIS_DECL:.*]]: DW_TAG_formal_parameter
44 ; CHECK: DW_TAG_formal_parameter
4545
4646 ; The abstract definition of C::m_fn2
4747 ; CHECK: [[M_FN2_ABS_DEF:.*]]: DW_TAG_subprogram
4848 ; CHECK-NOT: DW_TAG
49 ; CHECK: DW_AT_specification {{.*}} "_ZN1C5m_fn2Ev"
49 ; CHECK: DW_AT_specification {{.*}} {[[M_FN2_DECL]]}
5050 ; CHECK-NOT: DW_TAG
5151 ; CHECK: DW_AT_inline
5252 ; CHECK-NOT: {{DW_TAG|NULL}}
6262 ; The concrete definition of C::m_fn2
6363 ; CHECK: DW_TAG_subprogram
6464 ; CHECK-NOT: DW_TAG
65 ; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]} "_ZN1C5m_fn2Ev"
65 ; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]}
6666 ; CHECK-NOT: {{DW_TAG|NULL}}
6767 ; CHECK: DW_TAG_formal_parameter
6868 ; CHECK-NOT: DW_TAG
7777 ; Inlined C::m_fn2:
7878 ; CHECK: DW_TAG_inlined_subroutine
7979 ; CHECK-NOT: DW_TAG
80 ; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]} "_ZN1C5m_fn2Ev"
80 ; CHECK: DW_AT_abstract_origin {{.*}} {[[M_FN2_ABS_DEF]]}
8181 ; CHECK-NOT: {{DW_TAG|NULL}}
8282 ; CHECK: DW_TAG_formal_parameter
8383 ; CHECK-NOT: DW_TAG
0 ; REQUIRES: object-emission
11
2 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck -implicit-check-not=DW_TAG %s
3 ; RUN: %llc_dwarf -dwarf-accel-tables=Enable -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
2 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=Enable < %s | llvm-dwarfdump -debug-dump=info - | FileCheck -implicit-check-not=DW_TAG %s
3 ; RUN: %llc_dwarf -dwarf-accel-tables=Enable -dwarf-linkage-names=Enable -O0 -filetype=obj < %s | llvm-dwarfdump - | FileCheck --check-prefix=CHECK-ACCEL --check-prefix=CHECK %s
44
55 ; Build from source:
66 ; $ clang++ a.cpp b.cpp -g -c -emit-llvm
0 ; REQUIRES: object-emission
11 ;
2 ; RUN: %llc_dwarf -filetype=obj -O0 < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: %llc_dwarf -filetype=obj -O0 -dwarf-linkage-names=Enable < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
33
44 ; Make sure we can handle enums with the same identifier but in enum types of
55 ; different compile units.
3737
3838 ; CHECK: DW_TAG_structure_type
3939 ; CHECK-NEXT: DW_AT_name {{.*}} "C"
40 ; CHECK: DW_TAG_subprogram
41 ; CHECK-NOT: DW_TAG
40 ; CHECK: [[M_FN3_DECL:.*]]: DW_TAG_subprogram
41 ; CHECK-NOT: {{DW_TAG|NULL}}
4242 ; CHECK: DW_AT_name {{.*}} "m_fn3"
4343
44 ; CHECK: DW_AT_specification {{.*}} "_ZN1C5m_fn3Ev"
44 ; CHECK: DW_AT_specification {{.*}} {[[M_FN3_DECL]]}
4545 ; CHECK-NOT: DW_TAG
4646 ; CHECK: DW_TAG_formal_parameter
4747 ; CHECK-NOT: DW_TAG
3636 ; x(u);
3737 ; }
3838
39 ; CHECK: DW_TAG_subprogram
39 ; CHECK: [[X_DECL:.*]]: DW_TAG_subprogram
4040 ; CHECK-NOT: DW_TAG
4141 ; CHECK: DW_AT_name {{.*}} "x"
4242 ; CHECK-NOT: {{DW_TAG|NULL}}
5656 ; CHECK-NOT: {{DW_TAG|NULL}}
5757 ; CHECK: DW_TAG_inlined_subroutine
5858 ; CHECK-NOT: DW_TAG
59 ; CHECK: DW_AT_abstract_origin {{.*}} "_Z1xb"
59 ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]}
6060 ; CHECK-NOT: {{DW_TAG|NULL}}
6161 ; CHECK: DW_TAG_formal_parameter
6262 ; CHECK-NOT: DW_TAG
7777 ; CHECK-NOT: {{DW_TAG|NULL}}
7878 ; CHECK: DW_TAG_inlined_subroutine
7979 ; CHECK-NOT: DW_TAG
80 ; CHECK: DW_AT_abstract_origin {{.*}} "_Z1xb"
80 ; CHECK: DW_AT_abstract_origin {{.*}} {[[X_DECL]]}
8181 ; CHECK-NOT: {{DW_TAG|NULL}}
8282 ; FIXME: This formal parameter goes missing at least at -O2 (& on
8383 ; mips/powerpc), maybe before that. Perhaps SelectionDAG is to blame (and
0 ; REQUIRES: object-emission
11
2 ; RUN: %llc_dwarf -O0 -filetype=obj < %s > %t
3 ; RUN: llvm-dwarfdump %t | FileCheck %s
2 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=Enable < %s | llvm-dwarfdump - | FileCheck %s
43 ; CHECK: debug_info contents
54 ; CHECK: [[NS1:0x[0-9a-f]*]]:{{ *}}DW_TAG_namespace
65 ; CHECK-NEXT: DW_AT_name{{.*}} = "A"
0 ; REQUIRES: object-emission
11
2 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=Enable < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
33
44 ; Generated from clang with the following source:
55 ; namespace ns {
0 ; REQUIRES: object-emission
11
2 ; RUN: %llc_dwarf -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: %llc_dwarf -O0 -filetype=obj -dwarf-linkage-names=Enable < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
33
44 ; Generate from clang with the following source. Note that the definition of
55 ; the inline function follows its use to workaround another bug that should be
0 ; REQUIRES: object-emission, native
11 ;
2 ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - | %llc_dwarf -filetype=obj -O0 | llvm-dwarfdump -debug-dump=info - | FileCheck %s
2 ; RUN: llvm-link %s %p/type-unique-odr-b.ll -S -o - | %llc_dwarf -dwarf-linkage-names=Enable -filetype=obj -O0 | llvm-dwarfdump -debug-dump=info - | FileCheck %s
33 ;
44 ; Test ODR-based type uniquing for C++ class members.
55 ; rdar://problem/15851313.
1717 ; return A().getFoo();
1818 ; }
1919 ;
20 ; CHECK: _ZN1A6setFooEv
20 ; CHECK: DW_AT_name {{.*}} "setFoo"
21 ; CHECK-NOT: DW_TAG
2122 ; CHECK: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
2223 ; CHECK-NOT: DW_AT_accessibility
2324 ; CHECK: DW_TAG
2222 ; CHECK: DW_TAG_class_type
2323 ; CHECK-NEXT: DW_AT_name {{.*}} "A"
2424 ; CHECK: DW_TAG_subprogram
25 ; CHECK: DW_AT_MIPS_linkage_name {{.*}} "_ZN1A5testAE2SA"
25 ; CHECK: DW_AT_name {{.*}} "testA"
2626 ; CHECK: DW_TAG_formal_parameter
2727 ; CHECK: DW_TAG_formal_parameter
2828 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x{{.*}} => {0x[[STRUCT:.*]]})
3333 ; CHECK: DW_TAG_class_type
3434 ; CHECK-NEXT: DW_AT_name {{.*}} "B"
3535 ; CHECK: DW_TAG_subprogram
36 ; CHECK: DW_AT_MIPS_linkage_name {{.*}} "_ZN1B5testBE2SA"
36 ; CHECK: DW_AT_name {{.*}} "testB"
3737 ; CHECK: DW_TAG_formal_parameter
3838 ; CHECK: DW_TAG_formal_parameter
3939 ; CHECK-NEXT: DW_AT_type [DW_FORM_ref_addr] {{.*}}[[STRUCT]]