blob: 35bf9a5168079a9acefca72c6fa4a2cb557d005a [file] [log] [blame]
Adrian Prantl3dd48c62015-01-07 20:48:58 +00001; RUN: llc %s -filetype=obj -o %t.o
2; RUN: llvm-dwarfdump -debug-dump=info %t.o | FileCheck %s
3; Test emitting a constant for an aggregate type.
4;
5; clang -S -O1 -emit-llvm
6;
7; typedef struct { unsigned i; } S;
8;
9; unsigned foo(S s) {
10; s.i = 1;
11; return s.i;
12; }
13;
14; class C { public: unsigned i; };
15;
16; unsigned foo(C c) {
17; c.i = 2;
18; return c.i;
19; }
20;
21; unsigned bar() {
22; int a[1] = { 3 };
23; return a[0];
24; }
25;
26; CHECK: DW_TAG_formal_parameter
27; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (1)
28; CHECK-NEXT: DW_AT_name {{.*}} "s"
29;
30; CHECK: DW_TAG_formal_parameter
31; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (2)
32; CHECK-NEXT: DW_AT_name {{.*}} "c"
33;
34; CHECK: DW_TAG_variable
35; CHECK-NEXT: DW_AT_const_value [DW_FORM_udata] (3)
36; CHECK-NEXT: DW_AT_name {{.*}} "a"
37
38; ModuleID = 'sroasplit-4.cpp'
39target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
40target triple = "x86_64-apple-macosx10.10.0"
41
42; Function Attrs: nounwind readnone ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000043define i32 @_Z3foo1S(i32 %s.coerce) #0 !dbg !12 {
Adrian Prantl3dd48c62015-01-07 20:48:58 +000044entry:
45 tail call void @llvm.dbg.value(metadata i32 %s.coerce, i64 0, metadata !18, metadata !37), !dbg !38
46 tail call void @llvm.dbg.value(metadata i32 1, i64 0, metadata !18, metadata !37), !dbg !38
47 ret i32 1, !dbg !39
48}
49
50; Function Attrs: nounwind readnone ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000051define i32 @_Z3foo1C(i32 %c.coerce) #0 !dbg !19 {
Adrian Prantl3dd48c62015-01-07 20:48:58 +000052entry:
53 tail call void @llvm.dbg.value(metadata i32 %c.coerce, i64 0, metadata !23, metadata !37), !dbg !40
54 tail call void @llvm.dbg.value(metadata i32 2, i64 0, metadata !23, metadata !37), !dbg !40
55 ret i32 2, !dbg !41
56}
57
58; Function Attrs: nounwind readnone ssp uwtable
Peter Collingbourned4bff302015-11-05 22:03:56 +000059define i32 @_Z3barv() #0 !dbg !24 {
Adrian Prantl3dd48c62015-01-07 20:48:58 +000060entry:
61 tail call void @llvm.dbg.value(metadata i32 3, i64 0, metadata !28, metadata !37), !dbg !42
62 ret i32 3, !dbg !43
63}
64
65; Function Attrs: nounwind readnone
66declare void @llvm.dbg.value(metadata, i64, metadata, metadata) #1
67
68attributes #0 = { nounwind readnone ssp uwtable }
69attributes #1 = { nounwind readnone }
70
71!llvm.dbg.cu = !{!0}
72!llvm.module.flags = !{!33, !34, !35}
73!llvm.ident = !{!36}
74
Duncan P. N. Exon Smith55ca9642015-08-03 17:26:41 +000075!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, producer: "clang version 3.6.0 (trunk 225364) (llvm/trunk 225366)", isOptimized: true, emissionKind: 1, file: !1, enums: !2, retainedTypes: !3, subprograms: !11, globals: !2, imports: !2)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000076!1 = !DIFile(filename: "sroasplit-4.cpp", directory: "")
Adrian Prantl3dd48c62015-01-07 20:48:58 +000077!2 = !{}
78!3 = !{!4, !8}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000079!4 = !DICompositeType(tag: DW_TAG_structure_type, line: 1, size: 32, align: 32, file: !1, elements: !5, identifier: "_ZTS1S")
Adrian Prantl3dd48c62015-01-07 20:48:58 +000080!5 = !{!6}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000081!6 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 1, size: 32, align: 32, file: !1, scope: !"_ZTS1S", baseType: !7)
82!7 = !DIBasicType(tag: DW_TAG_base_type, name: "unsigned int", size: 32, align: 32, encoding: DW_ATE_unsigned)
83!8 = !DICompositeType(tag: DW_TAG_class_type, name: "C", line: 8, size: 32, align: 32, file: !1, elements: !9, identifier: "_ZTS1C")
Adrian Prantl3dd48c62015-01-07 20:48:58 +000084!9 = !{!10}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000085!10 = !DIDerivedType(tag: DW_TAG_member, name: "i", line: 8, size: 32, align: 32, flags: DIFlagPublic, file: !1, scope: !"_ZTS1C", baseType: !7)
Adrian Prantl3dd48c62015-01-07 20:48:58 +000086!11 = !{!12, !19, !24}
Peter Collingbourned4bff302015-11-05 22:03:56 +000087!12 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo1S", line: 3, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 3, file: !1, scope: !13, type: !14, variables: !17)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000088!13 = !DIFile(filename: "sroasplit-4.cpp", directory: "")
89!14 = !DISubroutineType(types: !15)
Adrian Prantl3dd48c62015-01-07 20:48:58 +000090!15 = !{!7, !16}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000091!16 = !DIDerivedType(tag: DW_TAG_typedef, name: "S", line: 1, file: !1, baseType: !"_ZTS1S")
Adrian Prantl3dd48c62015-01-07 20:48:58 +000092!17 = !{!18}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000093!18 = !DILocalVariable(name: "s", line: 3, arg: 1, scope: !12, file: !13, type: !16)
Peter Collingbourned4bff302015-11-05 22:03:56 +000094!19 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foo1C", line: 10, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 10, file: !1, scope: !13, type: !20, variables: !22)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000095!20 = !DISubroutineType(types: !21)
Adrian Prantl3dd48c62015-01-07 20:48:58 +000096!21 = !{!7, !"_ZTS1C"}
97!22 = !{!23}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +000098!23 = !DILocalVariable(name: "c", line: 10, arg: 1, scope: !19, file: !13, type: !"_ZTS1C")
Peter Collingbourned4bff302015-11-05 22:03:56 +000099!24 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", line: 15, isLocal: false, isDefinition: true, flags: DIFlagPrototyped, isOptimized: true, scopeLine: 15, file: !1, scope: !13, type: !25, variables: !27)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000100!25 = !DISubroutineType(types: !26)
Adrian Prantl3dd48c62015-01-07 20:48:58 +0000101!26 = !{!7}
102!27 = !{!28}
Duncan P. N. Exon Smithed013cd2015-07-31 18:58:39 +0000103!28 = !DILocalVariable(name: "a", line: 16, scope: !24, file: !13, type: !29)
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000104!29 = !DICompositeType(tag: DW_TAG_array_type, size: 32, align: 32, baseType: !30, elements: !31)
105!30 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
Adrian Prantl3dd48c62015-01-07 20:48:58 +0000106!31 = !{!32}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000107!32 = !DISubrange(count: 1)
Adrian Prantl3dd48c62015-01-07 20:48:58 +0000108!33 = !{i32 2, !"Dwarf Version", i32 2}
Duncan P. N. Exon Smithe2741802015-03-03 17:24:31 +0000109!34 = !{i32 2, !"Debug Info Version", i32 3}
Adrian Prantl3dd48c62015-01-07 20:48:58 +0000110!35 = !{i32 1, !"PIC Level", i32 2}
111!36 = !{!"clang version 3.6.0 (trunk 225364) (llvm/trunk 225366)"}
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +0000112!37 = !DIExpression()
113!38 = !DILocation(line: 3, column: 16, scope: !12)
114!39 = !DILocation(line: 5, column: 3, scope: !12)
115!40 = !DILocation(line: 10, column: 16, scope: !19)
116!41 = !DILocation(line: 12, column: 3, scope: !19)
117!42 = !DILocation(line: 16, column: 6, scope: !24)
118!43 = !DILocation(line: 17, column: 3, scope: !24)