1 ; RUN: llc -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | llvm-dwarfdump - | FileCheck %s
2 ; RUN: llc --try-experimental-debuginfo-iterators -mtriple=x86_64-apple-darwin %s -o - -filetype=obj | llvm-dwarfdump - | FileCheck %s
4 ; CHECK: 0x00000[[G:.*]]: DW_TAG_variable
5 ; CHECK-NEXT: DW_AT_name ("g")
6 ; CHECK: DW_TAG_array_type
7 ; CHECK-NEXT: DW_AT_type ({{.*}} "int")
9 ; CHECK: DW_TAG_subrange_type
10 ; CHECK-NEXT: DW_AT_type ({{.*}} "__ARRAY_SIZE_TYPE__")
11 ; CHECK-NEXT: DW_AT_count (0x00000[[G]])
12 ; Test that a VLA referring to a global variable is handled correctly.
13 ; Clang doesn't generate this, but the verifier allows it.
14 source_filename = "/tmp/test.c"
15 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
16 target triple = "x86_64-apple-macosx10.13.0"
18 @g = common local_unnamed_addr global i32 0, align 4, !dbg !0
20 define void @f() !dbg !12 {
22 %0 = load i32, ptr @g, align 4, !dbg !22
23 %1 = zext i32 %0 to i64, !dbg !22
24 %vla = alloca i32, i64 %1, align 16, !dbg !22
25 call void @llvm.dbg.declare(metadata ptr %vla, metadata !16, metadata !DIExpression()), !dbg !22
26 call void @llvm.dbg.value(metadata i32 2, metadata !21, metadata !DIExpression()), !dbg !22
27 %call = call i32 (ptr, ...) @use(ptr nonnull %vla), !dbg !22
31 ; Function Attrs: nounwind readnone speculatable
32 declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
34 declare i32 @use(...) local_unnamed_addr
36 ; Function Attrs: nounwind readnone speculatable
37 declare void @llvm.dbg.value(metadata, metadata, metadata) #0
39 attributes #0 = { nounwind readnone speculatable }
42 !llvm.module.flags = !{!7, !8, !9, !10}
45 !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
46 !1 = distinct !DIGlobalVariable(name: "g", scope: !2, file: !3, line: 1, type: !6, isLocal: false, isDefinition: true)
47 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 7.0.0 (trunk 324259) (llvm/trunk 324261)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
48 !3 = !DIFile(filename: "/tmp/test.c", directory: "/")
51 !6 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
52 !7 = !{i32 2, !"Dwarf Version", i32 4}
53 !8 = !{i32 2, !"Debug Info Version", i32 3}
54 !9 = !{i32 1, !"wchar_size", i32 4}
55 !10 = !{i32 7, !"PIC Level", i32 2}
56 !11 = !{!"clang version 7.0.0 (trunk 324259) (llvm/trunk 324261)"}
57 !12 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 3, type: !13, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !2, retainedNodes: !15)
58 !13 = !DISubroutineType(types: !14)
61 !16 = !DILocalVariable(name: "array", scope: !12, file: !3, line: 4, type: !17)
62 !17 = !DICompositeType(tag: DW_TAG_array_type, baseType: !18, elements: !19)
63 !18 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
65 !20 = !DISubrange(count: !1)
66 !21 = !DILocalVariable(name: "count", scope: !12, file: !3, line: 5, type: !18)
67 !22 = !DILocation(line: 7, column: 1, scope: !12)