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 3 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") 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[[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. 14source_filename = "/tmp/test.c" 15target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" 16target triple = "x86_64-apple-macosx10.13.0" 17 18@g = common local_unnamed_addr global i32 0, align 4, !dbg !0 19 20define void @f() !dbg !12 { 21entry: 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 28 ret void, !dbg !22 29} 30 31; Function Attrs: nounwind readnone speculatable 32declare void @llvm.dbg.declare(metadata, metadata, metadata) #0 33 34declare i32 @use(...) local_unnamed_addr 35 36; Function Attrs: nounwind readnone speculatable 37declare void @llvm.dbg.value(metadata, metadata, metadata) #0 38 39attributes #0 = { nounwind readnone speculatable } 40 41!llvm.dbg.cu = !{!2} 42!llvm.module.flags = !{!7, !8, !9, !10} 43!llvm.ident = !{!11} 44 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: "/") 49!4 = !{} 50!5 = !{!0} 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) 59!14 = !{null} 60!15 = !{!16, !21} 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) 64!19 = !{!20} 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) 68