xref: /llvm-project/llvm/test/DebugInfo/X86/vla-dependencies.ll (revision 5a288fa32e0c91b211e39f3e370255916902f898)
1; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | llvm-dwarfdump - | FileCheck %s
2; CHECK:  DW_TAG_subprogram
3; CHECK:    DW_AT_name	("h")
4; CHECK: 0x00000[[VLAEXPR:.*]]:     DW_TAG_variable
5; CHECK-NEXT:    DW_AT_name	("vla_expr")
6; CHECK:        DW_TAG_array_type
7; CHECK-NEXT:     DW_AT_type	{{.*}}"int"
8; CHECK-NOT: DW_TAG
9; CHECK:        DW_TAG_subrange_type
10; CHECK-NEXT:     DW_AT_type {{.*}}"__ARRAY_SIZE_TYPE__"
11; CHECK-NEXT:     DW_AT_count	(0x00000[[VLAEXPR]]
12;
13;
14; Generated from (and then modified):
15;
16; #define DECLARE_ARRAY(type, var_name, size) type var_name[size]
17;
18; void h(void);
19; void k(ptr);
20;
21; void g() {
22;   h();
23; }
24;
25; void h() {
26;   int count = 2;
27;   DECLARE_ARRAY(int, array, count);
28;   k((ptr)array);
29; }
30source_filename = "/tmp/test.c"
31target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
32target triple = "x86_64-apple-macosx10.13.0"
33
34; Function Attrs: nounwind ssp uwtable
35define void @g() local_unnamed_addr #0 !dbg !10 {
36entry:
37  %vla2.i = alloca [2 x i32], align 16, !dbg !13
38  call void @llvm.dbg.declare(metadata ptr %vla2.i, metadata !20, metadata !DIExpression(DW_OP_stack_value)), !dbg !13
39  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %vla2.i), !dbg !25
40  call void @llvm.dbg.value(metadata i32 2, metadata !16, metadata !DIExpression()) #3, !dbg !25
41  call void @llvm.dbg.value(metadata i64 2, metadata !18, metadata !DIExpression()) #3, !dbg !13
42  call void @llvm.dbg.value(metadata i32 2, metadata !16, metadata !DIExpression()) #3, !dbg !25
43  call void @llvm.dbg.value(metadata i64 2, metadata !18, metadata !DIExpression()) #3, !dbg !13
44  call void @k(ptr nonnull %vla2.i) #3, !dbg !26
45  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %vla2.i), !dbg !27
46  ret void, !dbg !28
47}
48
49; Function Attrs: nounwind readnone speculatable
50declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
51
52declare void @k(ptr) local_unnamed_addr
53
54; Function Attrs: nounwind readnone speculatable
55declare void @llvm.dbg.value(metadata, metadata, metadata) #1
56
57; Function Attrs: argmemonly nounwind
58declare void @llvm.lifetime.start.p0(i64, ptr nocapture) #2
59
60; Function Attrs: argmemonly nounwind
61declare void @llvm.lifetime.end.p0(i64, ptr nocapture) #2
62
63attributes #0 = { nounwind ssp uwtable }
64attributes #1 = { nounwind readnone speculatable }
65attributes #2 = { argmemonly nounwind }
66attributes #3 = { nounwind }
67
68!llvm.dbg.cu = !{!0}
69!llvm.module.flags = !{!5, !6, !7, !8}
70!llvm.ident = !{!9}
71
72!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 7.0.0 (trunk 324259) (llvm/trunk 324261)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
73!1 = !DIFile(filename: "/tmp/test.c", directory: "/")
74!2 = !{}
75!3 = !{!4}
76!4 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)
77!5 = !{i32 2, !"Dwarf Version", i32 4}
78!6 = !{i32 2, !"Debug Info Version", i32 3}
79!7 = !{i32 1, !"wchar_size", i32 4}
80!8 = !{i32 7, !"PIC Level", i32 2}
81!9 = !{!"clang version 7.0.0 (trunk 324259) (llvm/trunk 324261)"}
82!10 = distinct !DISubprogram(name: "g", scope: !1, file: !1, line: 6, type: !11, isLocal: false, isDefinition: true, scopeLine: 6, isOptimized: true, unit: !0, retainedNodes: !2)
83!11 = !DISubroutineType(types: !12)
84!12 = !{null}
85!13 = !DILocation(line: 12, column: 3, scope: !14, inlinedAt: !24)
86!14 = distinct !DISubprogram(name: "h", scope: !1, file: !1, line: 10, type: !11, isLocal: false, isDefinition: true, scopeLine: 10, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !15)
87!15 = !{!16, !18, !20}
88!16 = !DILocalVariable(name: "count", scope: !14, file: !1, line: 11, type: !17)
89!17 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
90!18 = !DILocalVariable(name: "vla_expr", scope: !14, file: !1, line: 12, type: !19)
91!19 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
92!20 = !DILocalVariable(name: "array", scope: !14, file: !1, line: 12, type: !21)
93!21 = !DICompositeType(tag: DW_TAG_array_type, baseType: !17, elements: !22)
94!22 = !{!23}
95!23 = !DISubrange(count: !18)
96!24 = distinct !DILocation(line: 7, column: 3, scope: !10)
97!25 = !DILocation(line: 11, column: 7, scope: !14, inlinedAt: !24)
98!26 = !DILocation(line: 13, column: 3, scope: !14, inlinedAt: !24)
99!27 = !DILocation(line: 14, column: 1, scope: !14, inlinedAt: !24)
100!28 = !DILocation(line: 8, column: 1, scope: !10)
101