xref: /llvm-project/llvm/test/DebugInfo/X86/align_cpp11.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info -c -n S -n C0 -n C1 -n s -n E -n foo - \
2; RUN:   | FileCheck %s --implicit-check-not=DW_TAG
3
4; Generated by clang++ -c -g -std=c++11 -S -emit-llvm from the following C++11 source
5; struct S {
6;   char x;
7;   alignas(128) char xx;
8; };
9;
10; class alignas(64) C0 {
11; };
12;
13; class C1 {
14;   alignas(64) static ptr p;
15; };
16;
17; enum alignas(16) E {
18;   A,
19;   B,
20;   C,
21; };
22;
23; C0 c0;
24;
25; alignas(2048) S s;
26;
27; void foo()
28; {
29;     S ss;
30;     E e;
31;     C1 c1;
32;     alignas(32) int i = 42;
33;     auto Lambda = [i](){};
34; }
35
36; CHECK:   DW_TAG_class_type
37; CHECK:     DW_AT_name{{.*}}"C0"
38; CHECK:     DW_AT_alignment{{.*}}64
39
40; CHECK:   DW_TAG_variable
41; CHECK:     DW_AT_name{{.*}}"s"
42; CHECK:     DW_AT_alignment{{.*}}2048
43
44; CHECK:   DW_TAG_structure_type
45; CHECK:     DW_TAG_member
46; CHECK:     DW_TAG_member
47; CHECK:       DW_AT_name{{.*}}"xx"
48; CHECK:       DW_AT_alignment{{.*}}128
49
50; CHECK:   DW_TAG_enumeration_type
51; CHECK:     DW_AT_alignment{{.*}}16
52; CHECK:       DW_TAG_enumerator
53; CHECK:       DW_TAG_enumerator
54; CHECK:       DW_TAG_enumerator
55
56; CHECK:   DW_TAG_subprogram
57; CHECK:     DW_TAG_variable
58; CHECK:     DW_TAG_variable
59; CHECK:     DW_TAG_variable
60; CHECK:     DW_TAG_variable
61; CHECK:       DW_AT_name{{.*}}"i"
62; CHECK:       DW_AT_alignment{{.*}}32
63; CHECK:     DW_TAG_variable
64; CHECK:     DW_TAG_class_type
65; CHECK:       DW_TAG_member
66; CHECK:         DW_AT_name{{.*}}"i"
67; CHECK:         DW_AT_alignment{{.*}}32
68; CHECK:       DW_TAG_subprogram
69; CHECK:         DW_TAG_formal_parameter
70
71; CHECK:   DW_TAG_class_type
72; CHECK:     DW_AT_name{{.*}}"C1"
73; CHECK:     DW_TAG_member
74; CHECK:       DW_AT_name{{.*}}"p"
75; CHECK:       DW_AT_alignment{{.*}}64
76
77; ModuleID = 'test.cpp'
78source_filename = "test.cpp"
79target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
80target triple = "x86_64-unknown-linux-gnu"
81
82%class.C0 = type { [64 x i8] }
83%struct.S = type { i8, [127 x i8], i8, [127 x i8] }
84%class.C1 = type { i8 }
85%class.anon = type { i32 }
86
87@c0 = global %class.C0 zeroinitializer, align 64, !dbg !0
88@s = global %struct.S zeroinitializer, align 2048, !dbg !12
89
90; Function Attrs: nounwind uwtable
91define void @_Z3foov() #0 !dbg !24 {
92entry:
93  %ss = alloca %struct.S, align 128
94  %e = alloca i32, align 16
95  %c1 = alloca %class.C1, align 1
96  %i = alloca i32, align 32
97  %Lambda = alloca %class.anon, align 4
98  call void @llvm.dbg.declare(metadata ptr %ss, metadata !27, metadata !28), !dbg !29
99  call void @llvm.dbg.declare(metadata ptr %e, metadata !30, metadata !28), !dbg !31
100  call void @llvm.dbg.declare(metadata ptr %c1, metadata !32, metadata !28), !dbg !37
101  call void @llvm.dbg.declare(metadata ptr %i, metadata !38, metadata !28), !dbg !40
102  store i32 42, ptr %i, align 32, !dbg !40
103  call void @llvm.dbg.declare(metadata ptr %Lambda, metadata !41, metadata !28), !dbg !50
104  %0 = load i32, ptr %i, align 32, !dbg !52
105  store i32 %0, ptr %Lambda, align 4, !dbg !51
106  ret void, !dbg !53
107}
108
109; Function Attrs: nounwind readnone
110declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
111
112attributes #0 = { nounwind uwtable }
113attributes #1 = { nounwind readnone }
114
115!llvm.dbg.cu = !{!2}
116!llvm.module.flags = !{!21, !22}
117!llvm.ident = !{!23}
118
119!0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
120!1 = !DIGlobalVariable(name: "c0", scope: !2, file: !6, line: 19, type: !19, isLocal: false, isDefinition: true)
121!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 4.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !11)
122!3 = !DIFile(filename: "test.cpp", directory: "/tmp")
123!4 = !{!5}
124!5 = !DICompositeType(tag: DW_TAG_enumeration_type, name: "E", file: !6, line: 13, size: 32, align: 128, elements: !7, identifier: "_ZTS1E")
125!6 = !DIFile(filename: "./test.cpp", directory: "/tmp")
126!7 = !{!8, !9, !10}
127!8 = !DIEnumerator(name: "A", value: 0)
128!9 = !DIEnumerator(name: "B", value: 1)
129!10 = !DIEnumerator(name: "C", value: 2)
130!11 = !{!0, !12}
131!12 = distinct !DIGlobalVariableExpression(var: !13, expr: !DIExpression())
132!13 = !DIGlobalVariable(name: "s", scope: !2, file: !6, line: 21, type: !14, isLocal: false, isDefinition: true, align: 16384)
133!14 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "S", file: !6, line: 1, size: 2048, elements: !15, identifier: "_ZTS1S")
134!15 = !{!16, !18}
135!16 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !14, file: !6, line: 2, baseType: !17, size: 8)
136!17 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
137!18 = !DIDerivedType(tag: DW_TAG_member, name: "xx", scope: !14, file: !6, line: 3, baseType: !17, size: 8, align: 1024, offset: 1024)
138!19 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C0", file: !6, line: 6, size: 512, align: 512, elements: !20, identifier: "_ZTS2C0")
139!20 = !{}
140!21 = !{i32 2, !"Dwarf Version", i32 4}
141!22 = !{i32 2, !"Debug Info Version", i32 3}
142!23 = !{!"clang version 4.0.0"}
143!24 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !6, file: !6, line: 23, type: !25, isLocal: false, isDefinition: true, scopeLine: 24, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !20)
144!25 = !DISubroutineType(types: !26)
145!26 = !{null}
146!27 = !DILocalVariable(name: "ss", scope: !24, file: !6, line: 25, type: !14)
147!28 = !DIExpression()
148!29 = !DILocation(line: 25, column: 7, scope: !24)
149!30 = !DILocalVariable(name: "e", scope: !24, file: !6, line: 26, type: !5)
150!31 = !DILocation(line: 26, column: 7, scope: !24)
151!32 = !DILocalVariable(name: "c1", scope: !24, file: !6, line: 27, type: !33)
152!33 = distinct !DICompositeType(tag: DW_TAG_class_type, name: "C1", file: !6, line: 9, size: 8, elements: !34, identifier: "_ZTS2C1")
153!34 = !{!35}
154!35 = !DIDerivedType(tag: DW_TAG_member, name: "p", scope: !33, file: !6, line: 10, baseType: !36, align: 512, flags: DIFlagStaticMember)
155!36 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
156!37 = !DILocation(line: 27, column: 8, scope: !24)
157!38 = !DILocalVariable(name: "i", scope: !24, file: !6, line: 28, type: !39, align: 256)
158!39 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
159!40 = !DILocation(line: 28, column: 21, scope: !24)
160!41 = !DILocalVariable(name: "Lambda", scope: !24, file: !6, line: 29, type: !42)
161!42 = distinct !DICompositeType(tag: DW_TAG_class_type, scope: !24, file: !6, line: 29, size: 32, elements: !43)
162!43 = !{!44, !45}
163!44 = !DIDerivedType(tag: DW_TAG_member, name: "i", scope: !42, file: !6, line: 29, baseType: !39, size: 32, align: 256)
164!45 = !DISubprogram(name: "operator()", scope: !42, file: !6, line: 29, type: !46, isLocal: false, isDefinition: false, scopeLine: 29, flags: DIFlagPublic | DIFlagPrototyped, isOptimized: false)
165!46 = !DISubroutineType(types: !47)
166!47 = !{null, !48}
167!48 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !49, size: 64, flags: DIFlagArtificial | DIFlagObjectPointer)
168!49 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !42)
169!50 = !DILocation(line: 29, column: 10, scope: !24)
170!51 = !DILocation(line: 29, column: 19, scope: !24)
171!52 = !DILocation(line: 29, column: 20, scope: !24)
172!53 = !DILocation(line: 30, column: 1, scope: !24)
173
174