1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt < %s -mem2reg -S | FileCheck %s
4 ; Testing conversion from dbg.declare to dbg.value when the variable is a VLA.
6 ; We can't derive the size of the variable since it is a VLA with an unknown
9 ; Verify that we do not get a dbg.value after the phi node (we can't know if
10 ; the phi nodes result describes the whole array or not). Also verify that we
11 ; get a dbg.value that says that we do not know the value of the VLA in place
12 ; of the store (since we do not know which part of the VLA the store is
15 ; ModuleID = 'debug-alloca-vla.ll'
16 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
17 target triple = "x86_64-apple-macosx10.12.0"
19 ; Function Attrs: nounwind ssp uwtable
20 define void @scan(i32 %n) #0 !dbg !4 {
23 ; CHECK-NEXT: br label [[FOR_COND:%.*]], !dbg [[DBG10:![0-9]+]]
25 ; CHECK-NEXT: [[VLA1_0:%.*]] = phi i32 [ undef, [[ENTRY:%.*]] ], [ [[T0:%.*]], [[FOR_COND]] ]
26 ; CHECK-NEXT: [[T0]] = add i32 [[VLA1_0]], 1
27 ; CHECK-NEXT: call void @llvm.dbg.value(metadata i32 undef, metadata [[META11:![0-9]+]], metadata !DIExpression()), !dbg [[DBG19:![0-9]+]]
28 ; CHECK-NEXT: br label [[FOR_COND]], !dbg [[DBG10]]
31 %vla1 = alloca i32, i32 %n, align 8
32 call void @llvm.dbg.declare(metadata i32* %vla1, metadata !10, metadata !DIExpression()), !dbg !18
33 br label %for.cond, !dbg !18
35 for.cond: ; preds = %for.cond, %entry
36 %entryN = load i32, i32* %vla1, align 8, !dbg !18
37 %t0 = add i32 %entryN, 1
38 store i32 %t0, i32* %vla1, align 8, !dbg !18
39 br label %for.cond, !dbg !18
42 ; Function Attrs: nounwind readnone speculatable
43 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
45 attributes #0 = { nounwind ssp uwtable }
46 attributes #1 = { nounwind readnone speculatable }
49 !llvm.module.flags = !{!2, !3}
51 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "adrian", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
52 !1 = !DIFile(filename: "<stdin>", directory: "/")
53 !2 = !{i32 2, !"Debug Info Version", i32 3}
54 !3 = !{i32 7, !"PIC Level", i32 2}
55 !4 = distinct !DISubprogram(name: "scan", scope: !1, file: !1, line: 4, type: !5, isLocal: false, isDefinition: true, scopeLine: 5, flags: DIFlagPrototyped, isOptimized: true, unit: !0, retainedNodes: !8)
56 !5 = !DISubroutineType(types: !6)
58 !7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
60 !9 = !DILocalVariable(name: "entry", scope: !4, file: !1, line: 6, type: !7)
61 !10 = !DILocalVariable(name: "ptr32", scope: !4, file: !1, line: 240, type: !11)
62 !11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !12, elements: !14)
63 !12 = !DIDerivedType(tag: DW_TAG_typedef, name: "__uint32_t", file: !1, line: 41, baseType: !13)
64 !13 = !DIBasicType(name: "unsigned int", size: 32, encoding: DW_ATE_unsigned)
66 !15 = !DISubrange(count: !16)
67 !16 = !DILocalVariable(name: "__vla_expr", scope: !4, type: !17, flags: DIFlagArtificial)
68 !17 = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned)
69 !18 = !DILocation(line: 6, scope: !4)