blob: d9810b8528977e4100d7e4b260d2bf5bc3859286 [file] [log] [blame]
David Blaikiea1e813d2013-05-10 21:52:07 +00001; REQUIRES: object-emission
2
David Blaikief95485a2013-05-10 22:14:39 +00003; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s > %t
David Blaikiea1e813d2013-05-10 21:52:07 +00004; RUN: llvm-dwarfdump %t | FileCheck %s
5
6; IR generated with `clang++ -g -emit-llvm -S` from the following code:
David Blaikie2b380232013-06-22 18:59:11 +00007; template<int x, int*, template<typename> class y, int ...z> int func() { return 3; }
David Blaikiea1ae0e62013-08-01 20:30:22 +00008; template<typename> struct y_impl { struct nested { }; };
David Blaikie2b380232013-06-22 18:59:11 +00009; int glbl = func<3, &glbl, y_impl, 1, 2>();
David Blaikiea1ae0e62013-08-01 20:30:22 +000010; y_impl<int>::nested n;
David Blaikiea1e813d2013-05-10 21:52:07 +000011
12; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type
13; CHECK-NEXT: DW_AT_name{{.*}} = "int"
14
David Blaikiea1ae0e62013-08-01 20:30:22 +000015; CHECK: DW_TAG_structure_type
16; CHECK-NEXT: DW_AT_name{{.*}}"y_impl<int>"
17; CHECK-NOT: NULL
18; CHECK: DW_TAG_template_type_parameter
19
David Blaikie2b380232013-06-22 18:59:11 +000020; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, 1, 2>"
David Blaikiea1e813d2013-05-10 21:52:07 +000021; CHECK-NOT: NULL
22; CHECK: DW_TAG_template_value_parameter
23; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
24; CHECK-NEXT: DW_AT_name{{.*}}= "x"
25
26; This could be made shorter by encoding it as _sdata rather than data4, or
27; even as data1. DWARF strongly urges implementations to prefer
28; _sdata/_udata rather than dataN
29
Eric Christopher9d1daa82013-08-27 23:49:04 +000030; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(3)
David Blaikiea1e813d2013-05-10 21:52:07 +000031
32; CHECK: DW_TAG_template_value_parameter
Manman Ren73d697c2013-10-29 00:58:04 +000033; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]}
David Blaikiea1e813d2013-05-10 21:52:07 +000034
35; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use
36; the value immediately, rather than indirecting through the address.
37
Eric Christopher4a741042014-02-16 08:46:55 +000038; CHECK-NEXT: DW_AT_location [DW_FORM_exprloc]{{ *}}(<0xa> 03 00 00 00 00 00 00 00 00 9f )
David Blaikie2b380232013-06-22 18:59:11 +000039; CHECK-NOT: NULL
40
41; CHECK: DW_TAG_GNU_template_template_param
42; CHECK-NEXT: DW_AT_name{{.*}}= "y"
43; CHECK-NEXT: DW_AT_GNU_template_name{{.*}}= "y_impl"
44; CHECK-NOT: NULL
45
46; CHECK: DW_TAG_GNU_template_parameter_pack
47; CHECK-NOT: NULL
48; CHECK: DW_TAG_template_value_parameter
49; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
Eric Christopher9d1daa82013-08-27 23:49:04 +000050; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(1)
David Blaikie2b380232013-06-22 18:59:11 +000051; CHECK-NOT: NULL
52; CHECK: DW_TAG_template_value_parameter
53; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
Eric Christopher9d1daa82013-08-27 23:49:04 +000054; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(2)
David Blaikiea1e813d2013-05-10 21:52:07 +000055
Manman Ren73d697c2013-10-29 00:58:04 +000056; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type
57; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]}
58
David Blaikiea1ae0e62013-08-01 20:30:22 +000059%"struct.y_impl<int>::nested" = type { i8 }
David Blaikie2b380232013-06-22 18:59:11 +000060
David Blaikiea1e813d2013-05-10 21:52:07 +000061@glbl = global i32 0, align 4
David Blaikiea1ae0e62013-08-01 20:30:22 +000062@n = global %"struct.y_impl<int>::nested" zeroinitializer, align 1
David Blaikiea1e813d2013-05-10 21:52:07 +000063@llvm.global_ctors = appending global [1 x { i32, void ()* }] [{ i32, void ()* } { i32 65535, void ()* @_GLOBAL__I_a }]
64
65define internal void @__cxx_global_var_init() section ".text.startup" {
66entry:
Eric Christopher96eff3f2013-10-17 01:31:12 +000067 %call = call i32 @_Z4funcILi3EXadL_Z4glblEE6y_implJLi1ELi2EEEiv(), !dbg !33
68 store i32 %call, i32* @glbl, align 4, !dbg !33
69 ret void, !dbg !33
David Blaikiea1e813d2013-05-10 21:52:07 +000070}
71
72; Function Attrs: nounwind uwtable
David Blaikie2b380232013-06-22 18:59:11 +000073define linkonce_odr i32 @_Z4funcILi3EXadL_Z4glblEE6y_implJLi1ELi2EEEiv() #0 {
David Blaikiea1e813d2013-05-10 21:52:07 +000074entry:
Eric Christopher96eff3f2013-10-17 01:31:12 +000075 ret i32 3, !dbg !34
David Blaikiea1e813d2013-05-10 21:52:07 +000076}
77
78define internal void @_GLOBAL__I_a() section ".text.startup" {
79entry:
Eric Christopher96eff3f2013-10-17 01:31:12 +000080 call void @__cxx_global_var_init(), !dbg !35
81 ret void, !dbg !35
David Blaikiea1e813d2013-05-10 21:52:07 +000082}
83
Eric Christopher96eff3f2013-10-17 01:31:12 +000084attributes #0 = { nounwind uwtable "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" "unsafe-fp-math"="false" "use-soft-float"="false" }
David Blaikiea1e813d2013-05-10 21:52:07 +000085
86!llvm.dbg.cu = !{!0}
Manman Ren409558f2013-11-22 21:49:45 +000087!llvm.module.flags = !{!31, !36}
Eric Christopher96eff3f2013-10-17 01:31:12 +000088!llvm.ident = !{!32}
David Blaikiea1e813d2013-05-10 21:52:07 +000089
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000090!0 = !{!"0x11\004\00clang version 3.4 (trunk 192849) (llvm/trunk 192850)\000\00\000\00\000", !1, !2, !3, !9, !28, !2} ; [ DW_TAG_compile_unit ] [/usr/local/google/home/echristo/tmp/bar.cpp] [DW_LANG_C_plus_plus]
91!1 = !{!"bar.cpp", !"/usr/local/google/home/echristo/tmp"}
92!2 = !{}
93!3 = !{!4, !8}
94!4 = !{!"0x13\00y_impl<int>\002\008\008\000\000\000", !1, null, null, !2, null, !5, !"_ZTS6y_implIiE"} ; [ DW_TAG_structure_type ] [y_impl<int>] [line 2, size 8, align 8, offset 0] [def] [from ]
95!5 = !{!6}
96!6 = !{!"0x2f\00\000\000", null, !7, null} ; [ DW_TAG_template_type_parameter ]
97!7 = !{!"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]
98!8 = !{!"0x13\00nested\002\008\008\000\000\000", !1, !"_ZTS6y_implIiE", null, !2, null, null, !"_ZTSN6y_implIiE6nestedE"} ; [ DW_TAG_structure_type ] [nested] [line 2, size 8, align 8, offset 0] [def] [from ]
99!9 = !{!10, !14, !26}
100!10 = !{!"0x2e\00__cxx_global_var_init\00__cxx_global_var_init\00\003\001\001\000\006\00256\000\003", !1, !11, !12, null, void ()* @__cxx_global_var_init, null, null, !2} ; [ DW_TAG_subprogram ] [line 3] [local] [def] [__cxx_global_var_init]
101!11 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/usr/local/google/home/echristo/tmp/bar.cpp]
102!12 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !13, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
103!13 = !{null}
104!14 = !{!"0x2e\00func<3, &glbl, y_impl, 1, 2>\00func<3, &glbl, y_impl, 1, 2>\00_Z4funcILi3EXadL_Z4glblEE6y_implJLi1ELi2EEEiv\001\000\001\000\006\00256\000\001", !1, !11, !15, null, i32 ()* @_Z4funcILi3EXadL_Z4glblEE6y_implJLi1ELi2EEEiv, !17, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [func<3, &glbl, y_impl, 1, 2>]
105!15 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !16, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
106!16 = !{!7}
107!17 = !{!18, !19, !21, !22}
108!18 = !{!"0x30\00x\000\000", null, !7, i32 3, null} ; [ DW_TAG_template_value_parameter ]
109!19 = !{!"0x30\00\000\000", null, !20, i32* @glbl, null} ; [ DW_TAG_template_value_parameter ]
110!20 = !{!"0xf\00\000\0064\0064\000\000", null, null, !7} ; [ DW_TAG_pointer_type ] [line 0, size 64, align 64, offset 0] [from int]
111!21 = !{!"0x4106\00y\000\000", null, null, !"y_impl", null} ; [ DW_TAG_GNU_template_template_param ]
112!22 = !{!"0x4107\00z\000\000", null, null, !23, null} ; [ DW_TAG_GNU_template_parameter_pack ]
113!23 = !{!24, !25}
114!24 = !{!"0x30\00\000\000", null, !7, i32 1, null} ; [ DW_TAG_template_value_parameter ]
115!25 = !{!"0x30\00\000\000", null, !7, i32 2, null} ; [ DW_TAG_template_value_parameter ]
116!26 = !{!"0x2e\00\00\00_GLOBAL__I_a\001\001\001\000\006\0064\000\001", !1, !11, !27, null, void ()* @_GLOBAL__I_a, null, null, !2} ; [ DW_TAG_subprogram ] [line 1] [local] [def]
117!27 = !{!"0x15\00\000\000\000\000\000\000", i32 0, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
118!28 = !{!29, !30}
119!29 = !{!"0x34\00glbl\00glbl\00\003\000\001", null, !11, !7, i32* @glbl, null} ; [ DW_TAG_variable ] [glbl] [line 3] [def]
120!30 = !{!"0x34\00n\00n\00\004\000\001", null, !11, !8, %"struct.y_impl<int>::nested"* @n, null} ; [ DW_TAG_variable ] [n] [line 4] [def]
121!31 = !{i32 2, !"Dwarf Version", i32 4}
122!32 = !{!"clang version 3.4 (trunk 192849) (llvm/trunk 192850)"}
123!33 = !{i32 3, i32 0, !10, null}
124!34 = !{i32 1, i32 0, !14, null}
125!35 = !{i32 1, i32 0, !26, null}
126!36 = !{i32 1, !"Debug Info Version", i32 2}