blob: 1afb2621bed9c510ae955557bafad52c5ce224be [file] [log] [blame]
Eric Christopheraf7eca22014-03-13 23:26:25 +00001; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-unknown-linux-gnu -dwarf-version=4
David Blaikie49cfc8c2014-10-23 19:12:43 +00002; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=PRESENT
Eli Benderskye6abe832013-01-25 21:44:53 +00003; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=ABSENT
Eric Christopheraf7eca22014-03-13 23:26:25 +00004; RUN: llc %s -o %t -filetype=obj -O0 -mtriple=x86_64-apple-darwin -dwarf-version=4
Manman Ren584e4c02013-02-27 23:21:02 +00005; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DARWINP
6; RUN: llvm-dwarfdump -debug-dump=info %t | FileCheck %s -check-prefix=DARWINA
Eric Christopherce26df82013-01-16 19:53:47 +00007; Verify that attributes we do want are PRESENT;
8; verify that attributes we don't want are ABSENT.
9; It's a lot easier to do this in two passes than in one.
10; PR14471
11
David Blaikie9f4b70d2013-01-26 21:55:23 +000012; LLVM IR generated using: clang -emit-llvm -S -g
Eric Christopherce26df82013-01-16 19:53:47 +000013; (with the Clang part of this patch applied).
14;
15; class C
16; {
17; static int a;
David Blaikieb0859312013-01-19 23:00:25 +000018; const static bool const_a = true;
Eric Christopherce26df82013-01-16 19:53:47 +000019; protected:
20; static int b;
David Blaikiea39a76e2013-01-20 01:18:01 +000021; const static float const_b = 3.14;
Eric Christopherce26df82013-01-16 19:53:47 +000022; public:
23; static int c;
24; const static int const_c = 18;
25; int d;
26; };
27;
28; int C::a = 4;
29; int C::b = 2;
30; int C::c = 1;
31;
32; int main()
33; {
34; C instance_C;
35; instance_C.d = 8;
36; return C::c;
37; }
38
39%class.C = type { i32 }
40
41@_ZN1C1aE = global i32 4, align 4
42@_ZN1C1bE = global i32 2, align 4
43@_ZN1C1cE = global i32 1, align 4
44
45define i32 @main() nounwind uwtable {
46entry:
47 %retval = alloca i32, align 4
48 %instance_C = alloca %class.C, align 4
49 store i32 0, i32* %retval
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000050 call void @llvm.dbg.declare(metadata %class.C* %instance_C, metadata !29, metadata !{!"0x102"}), !dbg !30
David Blaikie79e6c742015-02-27 19:29:02 +000051 %d = getelementptr inbounds %class.C, %class.C* %instance_C, i32 0, i32 0, !dbg !31
David Blaikie9f4b70d2013-01-26 21:55:23 +000052 store i32 8, i32* %d, align 4, !dbg !31
David Blaikiea79ac142015-02-27 21:17:42 +000053 %0 = load i32, i32* @_ZN1C1cE, align 4, !dbg !32
David Blaikie9f4b70d2013-01-26 21:55:23 +000054 ret i32 %0, !dbg !32
Eric Christopherce26df82013-01-16 19:53:47 +000055}
56
Adrian Prantl87b7eb92014-10-01 18:55:02 +000057declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone
Eric Christopherce26df82013-01-16 19:53:47 +000058
59!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000060!llvm.module.flags = !{!34}
Eric Christopherce26df82013-01-16 19:53:47 +000061
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000062!0 = !{!"0x11\004\00clang version 3.3 (trunk 171914)\000\00\000\00\000", !33, !1, !1, !3, !10, !1} ; [ DW_TAG_compile_unit ] [/home/probinson/projects/upstream/static-member/test/debug-info-static-member.cpp] [DW_LANG_C_plus_plus]
63!1 = !{}
64!3 = !{!5}
65!5 = !{!"0x2e\00main\00main\00\0018\000\001\000\006\00256\000\0023", !33, !6, !7, null, i32 ()* @main, null, null, !1} ; [ DW_TAG_subprogram ] [line 18] [def] [scope 23] [main]
66!6 = !{!"0x29", !33} ; [ DW_TAG_file_type ]
67!7 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !8, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
68!8 = !{!9}
69!9 = !{!"0x24\00int\000\0032\0032\000\000\005", null, null} ; [ DW_TAG_base_type ] [int] [line 0, size 32, align 32, offset 0, enc DW_ATE_signed]
70!10 = !{!12, !27, !28}
71!12 = !{!"0x34\00a\00a\00_ZN1C1aE\0014\000\001", null, !6, !9, i32* @_ZN1C1aE, !15} ; [ DW_TAG_variable ] [a] [line 14] [def]
72!13 = !{!"0x2\00C\001\0032\0032\000\000\000", !33, null, null, !14, null, null, null} ; [ DW_TAG_class_type ] [C] [line 1, size 32, align 32, offset 0] [def] [from ]
73!14 = !{!15, !16, !19, !20, !23, !24, !26}
74!15 = !{!"0xd\00a\003\000\000\000\004097", !33, !13, !9, null} ; [ DW_TAG_member ] [a] [line 3, size 0, align 0, offset 0] [private] [static] [from int]
75!16 = !{!"0xd\00const_a\004\000\000\000\004097", !33, !13, !17, i1 true} ; [ DW_TAG_member ] [const_a] [line 4, size 0, align 0, offset 0] [private] [static] [from ]
76!17 = !{!"0x26\00\000\000\000\000\000", null, null, !18} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from bool]
77!18 = !{!"0x24\00bool\000\008\008\000\000\002", null, null} ; [ DW_TAG_base_type ] [bool] [line 0, size 8, align 8, offset 0, enc DW_ATE_boolean]
78!19 = !{!"0xd\00b\006\000\000\000\004098", !33, !13, !9, null} ; [ DW_TAG_member ] [b] [line 6, size 0, align 0, offset 0] [protected] [static] [from int]
79!20 = !{!"0xd\00const_b\007\000\000\000\004098", !33, !13, !21, float 0x40091EB860000000} ; [ DW_TAG_member ] [const_b] [line 7, size 0, align 0, offset 0] [protected] [static] [from ]
80!21 = !{!"0x26\00\000\000\000\000\000", null, null, !22} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from float]
81!22 = !{!"0x24\00float\000\0032\0032\000\000\004", null, null} ; [ DW_TAG_base_type ] [float] [line 0, size 32, align 32, offset 0, enc DW_ATE_float]
82!23 = !{!"0xd\00c\009\000\000\000\004099", !33, !13, !9, null} ; [ DW_TAG_member ] [c] [line 9, size 0, align 0, offset 0] [static] [from int]
83!24 = !{!"0xd\00const_c\0010\000\000\000\004099", !33, !13, !25, i32 18} ; [ DW_TAG_member ] [const_c] [line 10, size 0, align 0, offset 0] [static] [from ]
84!25 = !{!"0x26\00\000\000\000\000\000", null, null, !9} ; [ DW_TAG_const_type ] [line 0, size 0, align 0, offset 0] [from int]
85!26 = !{!"0xd\00d\0011\0032\0032\000\003", !33, !13, !9} ; [ DW_TAG_member ] [d] [line 11, size 32, align 32, offset 0] [from int]
86!27 = !{!"0x34\00b\00b\00_ZN1C1bE\0015\000\001", null, !6, !9, i32* @_ZN1C1bE, !19} ; [ DW_TAG_variable ] [b] [line 15] [def]
87!28 = !{!"0x34\00c\00c\00_ZN1C1cE\0016\000\001", null, !6, !9, i32* @_ZN1C1cE, !23} ; [ DW_TAG_variable ] [c] [line 16] [def]
88!29 = !{!"0x100\00instance_C\0020\000", !5, !6, !13} ; [ DW_TAG_auto_variable ] [instance_C] [line 20]
Duncan P. N. Exon Smith98854692015-01-14 22:27:36 +000089!30 = !MDLocation(line: 20, scope: !5)
90!31 = !MDLocation(line: 21, scope: !5)
91!32 = !MDLocation(line: 22, scope: !5)
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000092!33 = !{!"/usr/local/google/home/blaikie/Development/llvm/src/tools/clang/test/CodeGenCXX/debug-info-static-member.cpp", !"/home/blaikie/local/Development/llvm/build/clang/x86-64/Debug/llvm"}
Eric Christopherce26df82013-01-16 19:53:47 +000093; PRESENT verifies that static member declarations have these attributes:
94; external, declaration, accessibility, and either DW_AT_MIPS_linkage_name
95; (for variables) or DW_AT_const_value (for constants).
96;
97; PRESENT: .debug_info contents:
David Blaikie49cfc8c2014-10-23 19:12:43 +000098; PRESENT: DW_TAG_variable
99; PRESENT-NEXT: DW_AT_specification {{.*}} "a"
100; PRESENT-NEXT: DW_AT_location
101; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
Eric Christopherce26df82013-01-16 19:53:47 +0000102; PRESENT: DW_TAG_class_type
103; PRESENT-NEXT: DW_AT_name {{.*}} "C"
Frederic Rissd4de1802014-10-10 15:51:02 +0000104; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000105; PRESENT-NEXT: DW_AT_name {{.*}} "a"
106; PRESENT: DW_AT_external
107; PRESENT: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000108; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Eric Christopherce26df82013-01-16 19:53:47 +0000109; PRESENT: DW_TAG_member
110; PRESENT-NEXT: DW_AT_name {{.*}} "const_a"
111; PRESENT: DW_AT_external
112; PRESENT: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000113; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
David Blaikieb0859312013-01-19 23:00:25 +0000114; PRESENT: DW_AT_const_value {{.*}} (1)
Frederic Rissd4de1802014-10-10 15:51:02 +0000115; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000116; PRESENT-NEXT: DW_AT_name {{.*}} "b"
Frederic Riss878065b2014-09-04 19:39:20 +0000117; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
Eric Christopherce26df82013-01-16 19:53:47 +0000118; PRESENT: DW_TAG_member
119; PRESENT-NEXT: DW_AT_name {{.*}} "const_b"
Frederic Riss878065b2014-09-04 19:39:20 +0000120; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
David Blaikiec05c8f42014-05-11 15:47:39 +0000121; PRESENT: DW_AT_const_value [DW_FORM_udata] (1078523331)
Frederic Rissd4de1802014-10-10 15:51:02 +0000122; PRESENT: DW_TAG_member
Eric Christopherce26df82013-01-16 19:53:47 +0000123; PRESENT-NEXT: DW_AT_name {{.*}} "c"
Frederic Riss878065b2014-09-04 19:39:20 +0000124; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopherce26df82013-01-16 19:53:47 +0000125; PRESENT: DW_TAG_member
126; PRESENT-NEXT: DW_AT_name {{.*}} "const_c"
Frederic Riss878065b2014-09-04 19:39:20 +0000127; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopher9d1daa82013-08-27 23:49:04 +0000128; PRESENT: DW_AT_const_value {{.*}} (18)
Eric Christopherce26df82013-01-16 19:53:47 +0000129; While we're here, a normal member has data_member_location and
130; accessibility attributes.
131; PRESENT: DW_TAG_member
132; PRESENT-NEXT: DW_AT_name {{.*}} "d"
133; PRESENT: DW_AT_data_member_location
Frederic Riss878065b2014-09-04 19:39:20 +0000134; PRESENT: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopherce26df82013-01-16 19:53:47 +0000135; PRESENT: NULL
136; Definitions point back to their declarations, and have a location.
137; PRESENT: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000138; PRESENT-NEXT: DW_AT_specification {{.*}} "b"
Eric Christopherce26df82013-01-16 19:53:47 +0000139; PRESENT-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000140; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
Eric Christopherce26df82013-01-16 19:53:47 +0000141; PRESENT: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000142; PRESENT-NEXT: DW_AT_specification {{.*}} "c"
Eric Christopherce26df82013-01-16 19:53:47 +0000143; PRESENT-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000144; PRESENT-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
Eric Christopherce26df82013-01-16 19:53:47 +0000145
Manman Ren584e4c02013-02-27 23:21:02 +0000146; For Darwin gdb:
147; DARWINP: .debug_info contents:
David Blaikie49cfc8c2014-10-23 19:12:43 +0000148; DARWINP: DW_TAG_variable
149; DARWINP-NEXT: DW_AT_specification {{.*}} "a"
150; DARWINP-NEXT: DW_AT_location
151; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1aE"
Manman Ren584e4c02013-02-27 23:21:02 +0000152; DARWINP: DW_TAG_class_type
153; DARWINP-NEXT: DW_AT_name {{.*}} "C"
Frederic Rissd4de1802014-10-10 15:51:02 +0000154; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000155; DARWINP-NEXT: DW_AT_name {{.*}} "a"
156; DARWINP: DW_AT_external
157; DARWINP: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000158; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Manman Ren584e4c02013-02-27 23:21:02 +0000159; DARWINP: DW_TAG_member
160; DARWINP-NEXT: DW_AT_name {{.*}} "const_a"
161; DARWINP: DW_AT_external
162; DARWINP: DW_AT_declaration
Frederic Riss878065b2014-09-04 19:39:20 +0000163; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_private)
Manman Ren584e4c02013-02-27 23:21:02 +0000164; DARWINP: DW_AT_const_value {{.*}} (1)
Frederic Rissd4de1802014-10-10 15:51:02 +0000165; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000166; DARWINP-NEXT: DW_AT_name {{.*}} "b"
Frederic Riss878065b2014-09-04 19:39:20 +0000167; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
Manman Ren584e4c02013-02-27 23:21:02 +0000168; DARWINP: DW_TAG_member
169; DARWINP-NEXT: DW_AT_name {{.*}} "const_b"
Frederic Riss878065b2014-09-04 19:39:20 +0000170; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_protected)
David Blaikiec05c8f42014-05-11 15:47:39 +0000171; DARWINP: DW_AT_const_value [DW_FORM_udata] (1078523331)
Frederic Rissd4de1802014-10-10 15:51:02 +0000172; DARWINP: DW_TAG_member
Manman Ren584e4c02013-02-27 23:21:02 +0000173; DARWINP-NEXT: DW_AT_name {{.*}} "c"
Frederic Riss878065b2014-09-04 19:39:20 +0000174; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Manman Ren584e4c02013-02-27 23:21:02 +0000175; DARWINP: DW_TAG_member
176; DARWINP-NEXT: DW_AT_name {{.*}} "const_c"
Frederic Riss878065b2014-09-04 19:39:20 +0000177; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Eric Christopher9d1daa82013-08-27 23:49:04 +0000178; DARWINP: DW_AT_const_value {{.*}} (18)
Manman Ren584e4c02013-02-27 23:21:02 +0000179; While we're here, a normal member has data_member_location and
180; accessibility attributes.
181; DARWINP: DW_TAG_member
182; DARWINP-NEXT: DW_AT_name {{.*}} "d"
183; DARWINP: DW_AT_data_member_location
Frederic Riss878065b2014-09-04 19:39:20 +0000184; DARWINP: DW_AT_accessibility [DW_FORM_data1] (DW_ACCESS_public)
Manman Ren584e4c02013-02-27 23:21:02 +0000185; DARWINP: NULL
186; Definitions point back to their declarations, and have a location.
187; DARWINP: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000188; DARWINP-NEXT: DW_AT_specification {{.*}} "b"
Manman Ren584e4c02013-02-27 23:21:02 +0000189; DARWINP-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000190; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1bE"
Manman Ren584e4c02013-02-27 23:21:02 +0000191; DARWINP: DW_TAG_variable
Frederic Rissd4de1802014-10-10 15:51:02 +0000192; DARWINP-NEXT: DW_AT_specification {{.*}} "c"
Manman Ren584e4c02013-02-27 23:21:02 +0000193; DARWINP-NEXT: DW_AT_location
Eric Christopheraf7eca22014-03-13 23:26:25 +0000194; DARWINP-NEXT: DW_AT_linkage_name {{.*}} "_ZN1C1cE"
Manman Ren584e4c02013-02-27 23:21:02 +0000195
Eric Christopherce26df82013-01-16 19:53:47 +0000196; ABSENT verifies that static member declarations do not have either
197; DW_AT_location or DW_AT_data_member_location; also, variables do not
Eric Christopheraf7eca22014-03-13 23:26:25 +0000198; have DW_AT_const_value and constants do not have DW_AT_linkage_name.
Eric Christopherce26df82013-01-16 19:53:47 +0000199;
200; ABSENT: .debug_info contents:
201; ABSENT: DW_TAG_member
202; ABSENT: DW_AT_name {{.*}} "a"
203; ABSENT-NOT: DW_AT_const_value
204; ABSENT-NOT: location
205; ABSENT: DW_AT_name {{.*}} "const_a"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000206; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000207; ABSENT-NOT: location
208; ABSENT: DW_AT_name {{.*}} "b"
209; ABSENT-NOT: DW_AT_const_value
210; ABSENT-NOT: location
211; ABSENT: DW_AT_name {{.*}} "const_b"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000212; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000213; ABSENT-NOT: location
214; ABSENT: DW_AT_name {{.*}} "c"
215; ABSENT-NOT: DW_AT_const_value
216; ABSENT-NOT: location
217; ABSENT: DW_AT_name {{.*}} "const_c"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000218; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000219; ABSENT-NOT: location
220; While we're here, a normal member does not have a linkage name, constant
221; value, or DW_AT_location.
222; ABSENT: DW_AT_name {{.*}} "d"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000223; ABSENT-NOT: DW_AT_linkage_name
Eric Christopherce26df82013-01-16 19:53:47 +0000224; ABSENT-NOT: DW_AT_const_value
225; ABSENT-NOT: DW_AT_location
226; ABSENT: NULL
Manman Ren584e4c02013-02-27 23:21:02 +0000227
228; For Darwin gdb:
229; DARWINA: .debug_info contents:
230; DARWINA: DW_TAG_member
231; DARWINA: DW_AT_name {{.*}} "a"
232; DARWINA-NOT: DW_AT_const_value
233; DARWINA-NOT: location
234; DARWINA: DW_AT_name {{.*}} "const_a"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000235; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000236; DARWINA-NOT: location
237; DARWINA: DW_AT_name {{.*}} "b"
238; DARWINA-NOT: DW_AT_const_value
239; DARWINA-NOT: location
240; DARWINA: DW_AT_name {{.*}} "const_b"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000241; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000242; DARWINA-NOT: location
243; DARWINA: DW_AT_name {{.*}} "c"
244; DARWINA-NOT: DW_AT_const_value
245; DARWINA-NOT: location
246; DARWINA: DW_AT_name {{.*}} "const_c"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000247; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000248; DARWINA-NOT: location
249; While we're here, a normal member does not have a linkage name, constant
250; value, or DW_AT_location.
251; DARWINA: DW_AT_name {{.*}} "d"
Eric Christopheraf7eca22014-03-13 23:26:25 +0000252; DARWINA-NOT: DW_AT_linkage_name
Manman Ren584e4c02013-02-27 23:21:02 +0000253; DARWINA-NOT: DW_AT_const_value
254; DARWINA-NOT: DW_AT_location
255; DARWINA: NULL
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000256!34 = !{i32 1, !"Debug Info Version", i32 2}