[Verifier] Check that debug values have proper size
[oota-llvm.git] / test / DebugInfo / X86 / dbg-value-terminator.ll
1 ; RUN: llc -mtriple=x86_64-apple-macosx < %s -verify-machineinstrs | FileCheck %s
2 ;
3 ; PR16143: MachineOperand::setIsKill(bool): Assertion
4 ;
5 ; verify-machineinstrs should ensure that DEBUG_VALUEs go before the
6 ; terminator.
7 ;
8 ; CHECK-LABEL: test:
9 ; CHECK: ##DEBUG_VALUE: foo:i
10
11 %a = type { i32, i32 }
12
13 define hidden fastcc %a* @test() #1 !dbg !1 {
14 entry:
15   %0 = icmp eq %a* undef, null, !dbg !12
16   br i1 %0, label %"14", label %return, !dbg !12
17
18 "14":                                             ; preds = %"8"
19   br i1 undef, label %"25", label %"21", !dbg !12
20
21 "21":                                             ; preds = %"14"
22   br i1 undef, label %may_unswitch_on.exit, label %"6.i", !dbg !12
23
24 "6.i":                                            ; preds = %"21"
25   br i1 undef, label %"10.i", label %may_unswitch_on.exit, !dbg !12
26
27 "10.i":                                           ; preds = %"6.i"
28   br i1 undef, label %may_unswitch_on.exit, label %"12.i", !dbg !12
29
30 "12.i":                                           ; preds = %"10.i"
31   br i1 undef, label %"4.i.i", label %"3.i.i", !dbg !12
32
33 "3.i.i":                                          ; preds = %"12.i"
34   br i1 undef, label %"4.i.i", label %VEC_edge_base_index.exit.i, !dbg !12
35
36 "4.i.i":                                          ; preds = %"3.i.i", %"12.i"
37   unreachable, !dbg !12
38
39 VEC_edge_base_index.exit.i:                       ; preds = %"3.i.i"
40   br i1 undef, label %may_unswitch_on.exit, label %"16.i", !dbg !12
41
42 "16.i":                                           ; preds = %VEC_edge_base_index.exit.i
43   br i1 undef, label %"4.i6.i", label %"3.i5.i", !dbg !12
44
45 "3.i5.i":                                         ; preds = %"16.i"
46   br i1 undef, label %VEC_edge_base_index.exit7.i, label %"4.i6.i", !dbg !12
47
48 "4.i6.i":                                         ; preds = %"3.i5.i", %"16.i"
49   unreachable, !dbg !12
50
51 VEC_edge_base_index.exit7.i:                      ; preds = %"3.i5.i"
52   br i1 undef, label %may_unswitch_on.exit, label %"21.i", !dbg !12
53
54 "21.i":                                           ; preds = %VEC_edge_base_index.exit7.i
55   br i1 undef, label %may_unswitch_on.exit, label %"23.i", !dbg !12
56
57 "23.i":                                           ; preds = %"21.i"
58   br i1 undef, label %may_unswitch_on.exit, label %"26.i", !dbg !12
59
60 "26.i":                                           ; preds = %"34.i", %"23.i"
61   %1 = icmp eq i32 undef, 9, !dbg !12
62   br i1 %1, label %"34.i", label %"28.i", !dbg !12
63
64 "28.i":                                           ; preds = %"26.i"
65   unreachable
66
67 "34.i":                                           ; preds = %"26.i"
68   br i1 undef, label %"26.i", label %"36.i", !dbg !12
69
70 "36.i":                                           ; preds = %"34.i"
71   br i1 undef, label %"37.i", label %"38.i", !dbg !12
72
73 "37.i":                                           ; preds = %"36.i"
74   br label %"38.i", !dbg !12
75
76 "38.i":                                           ; preds = %"37.i", %"36.i"
77   br i1 undef, label %"39.i", label %"45.i", !dbg !12
78
79 "39.i":                                           ; preds = %"38.i"
80   br i1 undef, label %"41.i", label %may_unswitch_on.exit, !dbg !12
81
82 "41.i":                                           ; preds = %"39.i"
83   br i1 undef, label %may_unswitch_on.exit, label %"42.i", !dbg !12
84
85 "42.i":                                           ; preds = %"41.i"
86   br i1 undef, label %may_unswitch_on.exit, label %"44.i", !dbg !12
87
88 "44.i":                                           ; preds = %"42.i"
89   %2 = load %a*, %a** undef, align 8, !dbg !12
90   %3 = bitcast %a* %2 to %a*, !dbg !12
91   call void @llvm.dbg.value(metadata %a* %3, i64 0, metadata !6, metadata !DIExpression(DW_OP_deref)), !dbg !12
92   br label %may_unswitch_on.exit, !dbg !12
93
94 "45.i":                                           ; preds = %"38.i"
95   unreachable
96
97 may_unswitch_on.exit:                             ; preds = %"44.i", %"42.i", %"41.i", %"39.i", %"23.i", %"21.i", %VEC_edge_base_index.exit7.i, %VEC_edge_base_index.exit.i, %"10.i", %"6.i", %"21"
98   %4 = phi %a* [ %3, %"44.i" ], [ null, %"6.i" ], [ null, %"10.i" ], [ null, %VEC_edge_base_index.exit7.i ], [ null, %VEC_edge_base_index.exit.i ], [ null, %"21.i" ], [ null, %"23.i" ], [ null, %"39.i" ], [ null, %"42.i" ], [ null, %"41.i" ], [ null, %"21" ]
99   br label %return
100
101 "25":                                             ; preds = %"14"
102   unreachable
103
104 "return":
105   %result = phi %a* [ null, %entry ], [ %4, %may_unswitch_on.exit ]
106   ret %a* %result, !dbg !12
107 }
108
109 attributes #0 = { nounwind readnone }
110 attributes #1 = { nounwind uwtable }
111
112 declare void @llvm.dbg.value(metadata, i64, metadata, metadata) nounwind readnone
113
114 !llvm.dbg.cu = !{!0}
115 !llvm.module.flags = !{!22}
116
117 !0 = distinct !DICompileUnit(language: DW_LANG_C99, producer: "Apple clang version", isOptimized: true, emissionKind: 1, file: !20, enums: !21, retainedTypes: !21, subprograms: !18, imports:  null)
118 !1 = distinct !DISubprogram(name: "foo", line: 2, isLocal: false, isDefinition: true, virtualIndex: 6, flags: DIFlagPrototyped, isOptimized: true, file: !20, scope: !2, type: !3, variables: !19)
119 !2 = !DIFile(filename: "a.c", directory: "/private/tmp")
120 !3 = !DISubroutineType(types: !4)
121 !4 = !{!5}
122 !5 = !DIBasicType(tag: DW_TAG_base_type, name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
123 !6 = !DILocalVariable(name: "i", line: 2, arg: 1, scope: !1, file: !2, type: !5)
124 !7 = !DILocalVariable(name: "c", line: 2, arg: 2, scope: !1, file: !2, type: !8)
125 !8 = !DIDerivedType(tag: DW_TAG_pointer_type, size: 64, align: 64, scope: !0, baseType: !9)
126 !9 = !DIBasicType(tag: DW_TAG_base_type, name: "char", size: 8, align: 8, encoding: DW_ATE_signed_char)
127 !10 = !DILocalVariable(name: "a", line: 3, scope: !11, file: !2, type: !9)
128 !11 = distinct !DILexicalBlock(line: 2, column: 25, file: !20, scope: !1)
129 !12 = !DILocation(line: 2, column: 13, scope: !1)
130 !18 = !{!1}
131 !19 = !{!6, !7, !10}
132 !20 = !DIFile(filename: "a.c", directory: "/private/tmp")
133 !21 = !{}
134 !22 = !{i32 1, !"Debug Info Version", i32 3}