1 ; RUN: llc %s -stop-before=finalize-isel -o - \
2 ; RUN: -experimental-debug-variable-locations=true \
5 ;; Copy of DebugInfo/COFF/types-array-advanced.ll. This features a dbg.declare
6 ;; of something (dynamic alloca) that isn't an argument, causing a SDDbgValue
7 ;; with the indirect flag set to be emitted. Test that it's preserved in
8 ;; instruction referencing mode -- we don't have an IsIndirect flag on
9 ;; DBG_INSTR_REF, so it gets encoded as an additional DW_OP_deref.
11 ;; NB: the original test has an additional spurious DW_OP_deref in the
12 ;; dbg.declare's arguments, which is preserved here, translating to two derefs.
14 ; CHECK: DBG_INSTR_REF !{{[0-9]+}}, !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_deref, DW_OP_deref), dbg-instr-ref(1, 2)
\r
16 source_filename = "test/DebugInfo/COFF/types-array-advanced.ll"
17 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
18 target triple = "i686-pc-windows-msvc18.0.31101"
20 %struct.incomplete_struct = type { i32 }
22 @"\01?multi_dim_arr@@3PAY146DA" = global [2 x [5 x [7 x i8]]] zeroinitializer, align 1, !dbg !0
23 @"\01?p_incomplete_struct_arr@@3PAY02Uincomplete_struct@@A" = global ptr null, align 4, !dbg !6
24 @"\01?incomplete_struct_arr@@3PAUincomplete_struct@@A" = global [3 x %struct.incomplete_struct] zeroinitializer, align 4, !dbg !16
25 @"\01?typedef_arr@@3SDHD" = constant [4 x i32] zeroinitializer, align 4, !dbg !18
27 ; Function Attrs: nounwind
28 define void @"\01?foo@@YAXH@Z"(i32 %x) #0 !dbg !35 {
30 %x.addr = alloca i32, align 4
31 %saved_stack = alloca ptr, align 4
32 store i32 %x, ptr %x.addr, align 4
33 %0 = load i32, ptr %x.addr, align 4, !dbg !41
34 %1 = call ptr @llvm.stacksave(), !dbg !42
35 store ptr %1, ptr %saved_stack, align 4, !dbg !42
36 %vla = alloca i32, i32 %0, align 4, !dbg !42
37 ;; This dbg.declare turns into a DBG_INSTR_REF, rather than an argument
38 ;; DBG_VALUE. It needs to keep the extra indirectness.
39 call void @llvm.dbg.declare(metadata ptr %vla, metadata !43, metadata !47), !dbg !48
40 store i32 0, ptr %vla, align 4, !dbg !50
41 %2 = load ptr, ptr %saved_stack, align 4, !dbg !51
42 call void @llvm.stackrestore(ptr %2), !dbg !51
46 ; Function Attrs: nounwind readnone
47 declare void @llvm.dbg.declare(metadata, metadata, metadata)
49 ; Function Attrs: nounwind
50 declare ptr @llvm.stacksave()
52 ; Function Attrs: nounwind
53 declare void @llvm.stackrestore(ptr)
56 !llvm.module.flags = !{!32, !33}
59 !0 = distinct !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
60 !1 = !DIGlobalVariable(name: "multi_dim_arr", linkageName: "\01?multi_dim_arr@@3PAY146DA", scope: !2, file: !3, line: 1, type: !26, isLocal: false, isDefinition: true)
61 !2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang version 3.9.0 (trunk 273874)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5)
62 !3 = !DIFile(filename: "t.cpp", directory: "/")
64 !5 = !{!0, !6, !16, !18}
65 !6 = distinct !DIGlobalVariableExpression(var: !7, expr: !DIExpression())
66 !7 = !DIGlobalVariable(name: "p_incomplete_struct_arr", linkageName: "\01?p_incomplete_struct_arr@@3PAY02Uincomplete_struct@@A", scope: !2, file: !3, line: 3, type: !8, isLocal: false, isDefinition: true)
67 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 32, align: 32)
68 !9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, elements: !14)
69 !10 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "incomplete_struct", file: !3, line: 4, size: 32, align: 32, elements: !11, identifier: ".?AUincomplete_struct@@")
71 !12 = !DIDerivedType(tag: DW_TAG_member, name: "s1", scope: !10, file: !3, line: 5, baseType: !13, size: 32, align: 32)
72 !13 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
74 !15 = !DISubrange(count: 3)
75 !16 = distinct !DIGlobalVariableExpression(var: !17, expr: !DIExpression())
76 !17 = !DIGlobalVariable(name: "incomplete_struct_arr", linkageName: "\01?incomplete_struct_arr@@3PAUincomplete_struct@@A", scope: !2, file: !3, line: 6, type: !9, isLocal: false, isDefinition: true)
77 !18 = distinct !DIGlobalVariableExpression(var: !19, expr: !DIExpression())
78 !19 = !DIGlobalVariable(name: "typedef_arr", linkageName: "\01?typedef_arr@@3SDHD", scope: !2, file: !3, line: 14, type: !20, isLocal: false, isDefinition: true)
79 !20 = !DICompositeType(tag: DW_TAG_array_type, baseType: !21, size: 128, align: 32, elements: !24)
80 !21 = !DIDerivedType(tag: DW_TAG_typedef, name: "T_INT", file: !3, line: 13, baseType: !22)
81 !22 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !23)
82 !23 = !DIDerivedType(tag: DW_TAG_volatile_type, baseType: !13)
84 !25 = !DISubrange(count: 4)
85 !26 = !DICompositeType(tag: DW_TAG_array_type, baseType: !27, size: 560, align: 8, elements: !28)
86 !27 = !DIBasicType(name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
87 !28 = !{!29, !30, !31}
88 !29 = !DISubrange(count: 2)
89 !30 = !DISubrange(count: 5)
90 !31 = !DISubrange(count: 7)
91 !32 = !{i32 2, !"CodeView", i32 1}
92 !33 = !{i32 2, !"Debug Info Version", i32 3}
93 !34 = !{!"clang version 3.9.0 (trunk 273874)"}
94 !35 = distinct !DISubprogram(name: "foo", linkageName: "\01?foo@@YAXH@Z", scope: !3, file: !3, line: 8, type: !36, isLocal: false, isDefinition: true, scopeLine: 8, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4)
95 !36 = !DISubroutineType(types: !37)
97 !38 = !DILocalVariable(name: "x", arg: 1, scope: !35, file: !3, line: 8, type: !13)
99 !40 = !DILocation(line: 8, column: 14, scope: !35)
100 !41 = !DILocation(line: 9, column: 21, scope: !35)
101 !42 = !DILocation(line: 9, column: 4, scope: !35)
102 !43 = !DILocalVariable(name: "dyn_size_arr", scope: !35, file: !3, line: 9, type: !44)
103 !44 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, align: 32, elements: !45)
105 !46 = !DISubrange(count: -1)
106 !47 = !DIExpression(DW_OP_deref)
107 !48 = !DILocation(line: 9, column: 8, scope: !35)
108 !49 = !DILocation(line: 10, column: 4, scope: !35)
109 !50 = !DILocation(line: 10, column: 20, scope: !35)
110 !51 = !DILocation(line: 11, column: 1, scope: !35)