xref: /llvm-project/llvm/test/DebugInfo/X86/align_c11.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc -filetype=obj < %s | llvm-dwarfdump -debug-info --name=data --name=d -c - \
2; RUN:   | FileCheck %s --implicit-check-not=DW_TAG
3
4; Generated by clang -c -g -std=c11 -S -emit-llvm from the following C11 source
5;
6; // every object of type struct data will be aligned to 128-byte boundary
7; struct data {
8;   char x;
9;   _Alignas(128) char arr[2];
10; };
11;
12; _Alignas(2048) struct data d; // this instance of data is aligned even stricter
13; int foo(void)
14; {
15;     struct data local_data;
16;     return 0;
17; }
18
19; CHECK:   DW_TAG_variable
20; CHECK:     DW_AT_name{{.*}}"d"
21; CHECK:     DW_AT_alignment{{.*}}2048
22
23; CHECK:   DW_TAG_structure_type
24; CHECK:     DW_TAG_member
25; CHECK:     DW_TAG_member
26; CHECK:       DW_AT_name{{.*}}"arr"
27; CHECK:       DW_AT_alignment{{.*}}128
28
29; ModuleID = 'test.c'
30source_filename = "test.c"
31target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
32target triple = "x86_64-unknown-linux-gnu"
33
34%struct.data = type { i8, [127 x i8], [2 x i8], [126 x i8] }
35
36@d = common global %struct.data zeroinitializer, align 2048, !dbg !0
37
38; Function Attrs: nounwind uwtable
39define i32 @foo() #0 !dbg !17 {
40entry:
41  %local_data = alloca %struct.data, align 128
42  call void @llvm.dbg.declare(metadata ptr %local_data, metadata !21, metadata !22), !dbg !23
43  ret i32 0, !dbg !24
44}
45
46; Function Attrs: nounwind readnone
47declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
48
49attributes #0 = { nounwind uwtable }
50attributes #1 = { nounwind readnone }
51
52!llvm.dbg.cu = !{!2}
53!llvm.module.flags = !{!14, !15}
54!llvm.ident = !{!16}
55
56!0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
57!1 = !DIGlobalVariable(name: "d", scope: !2, file: !3, line: 7, type: !6, isLocal: false, isDefinition: true, align: 16384)
58!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 4.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
59!3 = !DIFile(filename: "test.c", directory: "/tmp")
60!4 = !{}
61!5 = !{!0}
62!6 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "data", file: !3, line: 2, size: 2048, elements: !7)
63!7 = !{!8, !10}
64!8 = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: !6, file: !3, line: 3, baseType: !9, size: 8)
65!9 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
66!10 = !DIDerivedType(tag: DW_TAG_member, name: "arr", scope: !6, file: !3, line: 4, baseType: !11, size: 16, align: 1024, offset: 1024)
67!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !9, size: 16, elements: !12)
68!12 = !{!13}
69!13 = !DISubrange(count: 2)
70!14 = !{i32 2, !"Dwarf Version", i32 4}
71!15 = !{i32 2, !"Debug Info Version", i32 3}
72!16 = !{!"clang version 4.0.0"}
73!17 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 8, type: !18, isLocal: false, isDefinition: true, scopeLine: 9, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
74!18 = !DISubroutineType(types: !19)
75!19 = !{!20}
76!20 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
77!21 = !DILocalVariable(name: "local_data", scope: !17, file: !3, line: 10, type: !6)
78!22 = !DIExpression()
79!23 = !DILocation(line: 10, column: 17, scope: !17)
80!24 = !DILocation(line: 11, column: 5, scope: !17)
81
82