blob: 43e3727520fc67f5efa492fc4d28288c8c3090f1 [file] [log] [blame]
David Blaikiea1e813d2013-05-10 21:52:07 +00001; REQUIRES: object-emission
2
David Blaikie8b979f02014-12-17 00:43:22 +00003; RUN: llc -mtriple=x86_64-linux -O0 -filetype=obj < %s | llvm-dwarfdump -debug-dump=info - | FileCheck %s
David Blaikiea1e813d2013-05-10 21:52:07 +00004
5; IR generated with `clang++ -g -emit-llvm -S` from the following code:
David Blaikie8b979f02014-12-17 00:43:22 +00006; template<int x, int*, template<typename> class y, decltype(nullptr) n, int ...z> int func() { return 3; }
David Blaikiea1ae0e62013-08-01 20:30:22 +00007; template<typename> struct y_impl { struct nested { }; };
David Blaikie8b979f02014-12-17 00:43:22 +00008; int glbl = func<3, &glbl, y_impl, nullptr, 1, 2>();
David Blaikiea1ae0e62013-08-01 20:30:22 +00009; y_impl<int>::nested n;
David Blaikiea1e813d2013-05-10 21:52:07 +000010
11; CHECK: [[INT:0x[0-9a-f]*]]:{{ *}}DW_TAG_base_type
12; CHECK-NEXT: DW_AT_name{{.*}} = "int"
13
David Blaikiea1ae0e62013-08-01 20:30:22 +000014; CHECK: DW_TAG_structure_type
15; CHECK-NEXT: DW_AT_name{{.*}}"y_impl<int>"
16; CHECK-NOT: NULL
17; CHECK: DW_TAG_template_type_parameter
18
David Blaikie8b979f02014-12-17 00:43:22 +000019; CHECK: DW_AT_name{{.*}}"func<3, &glbl, y_impl, nullptr, 1, 2>"
David Blaikiea1e813d2013-05-10 21:52:07 +000020; CHECK-NOT: NULL
21; CHECK: DW_TAG_template_value_parameter
22; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
23; CHECK-NEXT: DW_AT_name{{.*}}= "x"
Eric Christopher9d1daa82013-08-27 23:49:04 +000024; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(3)
David Blaikiea1e813d2013-05-10 21:52:07 +000025
26; CHECK: DW_TAG_template_value_parameter
Manman Ren73d697c2013-10-29 00:58:04 +000027; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INTPTR:0x[0-9a-f]*]]}
David Blaikiea1e813d2013-05-10 21:52:07 +000028
29; The address of the global 'glbl', followed by DW_OP_stack_value (9f), to use
30; the value immediately, rather than indirecting through the address.
31
Eric Christopher4a741042014-02-16 08:46:55 +000032; 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 +000033; CHECK-NOT: NULL
34
35; CHECK: DW_TAG_GNU_template_template_param
36; CHECK-NEXT: DW_AT_name{{.*}}= "y"
37; CHECK-NEXT: DW_AT_GNU_template_name{{.*}}= "y_impl"
38; CHECK-NOT: NULL
39
David Blaikie8b979f02014-12-17 00:43:22 +000040; CHECK: DW_TAG_template_value_parameter
41; CHECK-NEXT: DW_AT_type{{.*}}=> {[[NULLPTR:0x[0-9a-f]*]]}
42; CHECK-NEXT: DW_AT_name{{.*}}= "n"
43; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata]{{.*}}(0)
44
David Blaikie2b380232013-06-22 18:59:11 +000045; CHECK: DW_TAG_GNU_template_parameter_pack
46; CHECK-NOT: NULL
47; CHECK: DW_TAG_template_value_parameter
48; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
Eric Christopher9d1daa82013-08-27 23:49:04 +000049; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(1)
David Blaikie2b380232013-06-22 18:59:11 +000050; CHECK-NOT: NULL
51; CHECK: DW_TAG_template_value_parameter
52; CHECK-NEXT: DW_AT_type{{.*}}=> {[[INT]]}
Eric Christopher9d1daa82013-08-27 23:49:04 +000053; CHECK-NEXT: DW_AT_const_value [DW_FORM_sdata]{{.*}}(2)
David Blaikiea1e813d2013-05-10 21:52:07 +000054
Manman Ren73d697c2013-10-29 00:58:04 +000055; CHECK: [[INTPTR]]:{{ *}}DW_TAG_pointer_type
56; CHECK-NEXT: DW_AT_type{{.*}} => {[[INT]]}
57
David Blaikie8b979f02014-12-17 00:43:22 +000058; CHECK: [[NULLPTR]]:{{ *}}DW_TAG_unspecified_type
59; CHECK-NEXT: DW_AT_name{{.*}}= "decltype(nullptr)"
60
David Blaikiea1ae0e62013-08-01 20:30:22 +000061%"struct.y_impl<int>::nested" = type { i8 }
David Blaikie2b380232013-06-22 18:59:11 +000062
David Blaikiea1e813d2013-05-10 21:52:07 +000063@glbl = global i32 0, align 4
David Blaikiea1ae0e62013-08-01 20:30:22 +000064@n = global %"struct.y_impl<int>::nested" zeroinitializer, align 1
David Blaikie8b979f02014-12-17 00:43:22 +000065@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @_GLOBAL__sub_I_template.cpp, i8* null }]
David Blaikiea1e813d2013-05-10 21:52:07 +000066
67define internal void @__cxx_global_var_init() section ".text.startup" {
68entry:
David Blaikie8b979f02014-12-17 00:43:22 +000069 %call = call i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv(), !dbg !36
70 store i32 %call, i32* @glbl, align 4, !dbg !36
71 ret void, !dbg !36
David Blaikiea1e813d2013-05-10 21:52:07 +000072}
73
74; Function Attrs: nounwind uwtable
David Blaikie8b979f02014-12-17 00:43:22 +000075define linkonce_odr i32 @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv() #0 {
David Blaikiea1e813d2013-05-10 21:52:07 +000076entry:
David Blaikie8b979f02014-12-17 00:43:22 +000077 ret i32 3, !dbg !37
David Blaikiea1e813d2013-05-10 21:52:07 +000078}
79
David Blaikie8b979f02014-12-17 00:43:22 +000080define internal void @_GLOBAL__sub_I_template.cpp() section ".text.startup" {
David Blaikiea1e813d2013-05-10 21:52:07 +000081entry:
David Blaikie8b979f02014-12-17 00:43:22 +000082 call void @__cxx_global_var_init(), !dbg !38
83 ret void
David Blaikiea1e813d2013-05-10 21:52:07 +000084}
85
Eric Christopher96eff3f2013-10-17 01:31:12 +000086attributes #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 +000087
88!llvm.dbg.cu = !{!0}
David Blaikie8b979f02014-12-17 00:43:22 +000089!llvm.module.flags = !{!33, !34}
90!llvm.ident = !{!35}
David Blaikiea1e813d2013-05-10 21:52:07 +000091
David Blaikie8b979f02014-12-17 00:43:22 +000092!0 = !{!"0x11\004\00clang version 3.6.0 (trunk 224394) (llvm/trunk 224384)\000\00\000\00\001", !1, !2, !3, !9, !30, !2} ; [ DW_TAG_compile_unit ] [/tmp/dbginfo/template.cpp] [DW_LANG_C_plus_plus]
93!1 = !{!"template.cpp", !"/tmp/dbginfo"}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000094!2 = !{}
95!3 = !{!4, !8}
96!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 ]
97!5 = !{!6}
David Blaikie8b979f02014-12-17 00:43:22 +000098!6 = !{!"0x2f\00\000\000", null, !7, null} ; [ DW_TAG_template_type_parameter ]
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +000099!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]
100!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 ]
David Blaikie8b979f02014-12-17 00:43:22 +0000101!9 = !{!10, !14, !28}
102!10 = !{!"0x2e\00__cxx_global_var_init\00__cxx_global_var_init\00\003\001\001\000\000\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]
103!11 = !{!"0x29", !1} ; [ DW_TAG_file_type ] [/tmp/dbginfo/template.cpp]
104!12 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !13, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000105!13 = !{null}
David Blaikie8b979f02014-12-17 00:43:22 +0000106!14 = !{!"0x2e\00func<3, &glbl, y_impl, nullptr, 1, 2>\00func<3, &glbl, y_impl, nullptr, 1, 2>\00_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv\001\000\001\000\000\00256\000\001", !1, !11, !15, null, i32 ()* @_Z4funcILi3EXadL_Z4glblEE6y_implLDn0EJLi1ELi2EEEiv, !17, null, !2} ; [ DW_TAG_subprogram ] [line 1] [def] [func<3, &glbl, y_impl, nullptr, 1, 2>]
107!15 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !16, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000108!16 = !{!7}
David Blaikie8b979f02014-12-17 00:43:22 +0000109!17 = !{!18, !19, !21, !22, !24}
Duncan P. N. Exon Smithbe7ea192014-12-15 19:07:53 +0000110!18 = !{!"0x30\00x\000\000", null, !7, i32 3, null} ; [ DW_TAG_template_value_parameter ]
111!19 = !{!"0x30\00\000\000", null, !20, i32* @glbl, null} ; [ DW_TAG_template_value_parameter ]
112!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]
113!21 = !{!"0x4106\00y\000\000", null, null, !"y_impl", null} ; [ DW_TAG_GNU_template_template_param ]
David Blaikie8b979f02014-12-17 00:43:22 +0000114!22 = !{!"0x30\00n\000\000", null, !23, i8 0, null} ; [ DW_TAG_template_value_parameter ]
115!23 = !{!"0x3b\00decltype(nullptr)\000\000\000\000\000\000", null, null} ; [ DW_TAG_unspecified_type ] [decltype(nullptr)] [line 0, size 0, align 0, offset 0]
116!24 = !{!"0x4107\00z\000\000", null, null, !25, null} ; [ DW_TAG_GNU_template_parameter_pack ]
117!25 = !{!26, !27}
118!26 = !{!"0x30\00\000\000", null, !7, i32 1, null} ; [ DW_TAG_template_value_parameter ]
119!27 = !{!"0x30\00\000\000", null, !7, i32 2, null} ; [ DW_TAG_template_value_parameter ]
120!28 = !{!"0x2e\00\00\00_GLOBAL__sub_I_template.cpp\000\001\001\000\000\0064\000\000", !1, !11, !29, null, void ()* @_GLOBAL__sub_I_template.cpp, null, null, !2} ; [ DW_TAG_subprogram ] [line 0] [local] [def]
121!29 = !{!"0x15\00\000\000\000\000\000\000", null, null, null, !2, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
122!30 = !{!31, !32}
123!31 = !{!"0x34\00glbl\00glbl\00\003\000\001", null, !11, !7, i32* @glbl, null} ; [ DW_TAG_variable ] [glbl] [line 3] [def]
124!32 = !{!"0x34\00n\00n\00\004\000\001", null, !11, !"_ZTSN6y_implIiE6nestedE", %"struct.y_impl<int>::nested"* @n, null} ; [ DW_TAG_variable ] [n] [line 4] [def]
125!33 = !{i32 2, !"Dwarf Version", i32 4}
126!34 = !{i32 2, !"Debug Info Version", i32 2}
127!35 = !{!"clang version 3.6.0 (trunk 224394) (llvm/trunk 224384)"}
128!36 = !{i32 3, i32 12, !10, null}
129!37 = !{i32 1, i32 96, !14, null}
130!38 = !{i32 0, i32 0, !28, null}