1 ; RUN: opt -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
2 ; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s
4 ; Emit a remark that reports a store.
5 define void @store(ptr %dst) {
6 ; CHECK: Store inserted by -ftrivial-auto-var-init.
7 ; CHECK-NEXT: Store size: 4 bytes.
8 ; YAML-LABEL: --- !Missed
9 ; YAML-NEXT: Pass: annotation-remarks
10 ; YAML-NEXT: Name: AutoInitStore
11 ; YAML-NEXT: DebugLoc:
12 ; YAML-NEXT: Function: store
14 ; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
15 ; YAML-NEXT: - String: "\nStore size: "
16 ; YAML-NEXT: - StoreSize: '4'
17 ; YAML-NEXT: - String: ' bytes.'
18 ; YAML-NEXT: - String: ' Volatile: '
19 ; YAML-NEXT: - StoreVolatile: 'false'
20 ; YAML-NEXT: - String: .
21 ; YAML-NEXT: - String: ' Atomic: '
22 ; YAML-NEXT: - StoreAtomic: 'false'
23 ; YAML-NEXT: - String: .
25 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
29 ; Emit a remark that reports a volatile store.
30 define void @volatile_store(ptr %dst) {
31 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
32 ; CHECK-NEXT: Store size: 4 bytes. Volatile: true.
33 ; YAML-LABEL: --- !Missed
34 ; YAML-NEXT: Pass: annotation-remarks
35 ; YAML-NEXT: Name: AutoInitStore
36 ; YAML-NEXT: DebugLoc:
37 ; YAML-NEXT: Function: volatile_store
39 ; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
40 ; YAML-NEXT: - String: "\nStore size: "
41 ; YAML-NEXT: - StoreSize: '4'
42 ; YAML-NEXT: - String: ' bytes.'
43 ; YAML-NEXT: - String: ' Volatile: '
44 ; YAML-NEXT: - StoreVolatile: 'true'
45 ; YAML-NEXT: - String: .
46 ; YAML-NEXT: - String: ' Atomic: '
47 ; YAML-NEXT: - StoreAtomic: 'false'
48 ; YAML-NEXT: - String: .
50 store volatile i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
54 ; Emit a remark that reports an atomic store.
55 define void @atomic_store(ptr %dst) {
56 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
57 ; CHECK-NEXT: Store size: 4 bytes. Atomic: true.
58 ; YAML-LABEL: --- !Missed
59 ; YAML-NEXT: Pass: annotation-remarks
60 ; YAML-NEXT: Name: AutoInitStore
61 ; YAML-NEXT: DebugLoc:
62 ; YAML-NEXT: Function: atomic_store
64 ; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
65 ; YAML-NEXT: - String: "\nStore size: "
66 ; YAML-NEXT: - StoreSize: '4'
67 ; YAML-NEXT: - String: ' bytes.'
68 ; YAML-NEXT: - String: ' Atomic: '
69 ; YAML-NEXT: - StoreAtomic: 'true'
70 ; YAML-NEXT: - String: .
71 ; YAML-NEXT: - String: ' Volatile: '
72 ; YAML-NEXT: - StoreVolatile: 'false'
73 ; YAML-NEXT: - String: .
75 store atomic i32 0, ptr %dst unordered, align 4, !annotation !0, !dbg !DILocation(scope: !4)
79 ; Emit a remark that reports a store to an alloca.
80 define void @store_alloca() {
81 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
82 ; CHECK-NEXT: Store size: 4 bytes.
83 ; CHECK-NEXT: Variables: dst (4 bytes).
84 ; YAML-LABEL: --- !Missed
85 ; YAML-NEXT: Pass: annotation-remarks
86 ; YAML-NEXT: Name: AutoInitStore
87 ; YAML-NEXT: DebugLoc:
88 ; YAML-NEXT: Function: store_alloca
90 ; YAML-NEXT: - String: Store inserted by -ftrivial-auto-var-init.
91 ; YAML-NEXT: - String: "\nStore size: "
92 ; YAML-NEXT: - StoreSize: '4'
93 ; YAML-NEXT: - String: ' bytes.'
94 ; YAML-NEXT: - String: "\n Written Variables: "
95 ; YAML-NEXT: - WVarName: dst
96 ; YAML-NEXT: - String: ' ('
97 ; YAML-NEXT: - WVarSize: '4'
98 ; YAML-NEXT: - String: ' bytes)'
99 ; YAML-NEXT: - String: .
100 ; YAML-NEXT: - String: ' Volatile: '
101 ; YAML-NEXT: - StoreVolatile: 'false'
102 ; YAML-NEXT: - String: .
103 ; YAML-NEXT: - String: ' Atomic: '
104 ; YAML-NEXT: - StoreAtomic: 'false'
105 ; YAML-NEXT: - String: .
108 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
112 ; Emit a remark that reports a store to an alloca through a GEP.
113 define void @store_alloca_gep() {
114 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
115 ; CHECK-NEXT: Store size: 4 bytes.
116 ; CHECK-NEXT: Variables: dst (4 bytes).
118 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
122 ; Emit a remark that reports a store to an alloca through a GEP, with ptrtoint+inttoptr in the way.
123 define void @store_alloca_gep_inttoptr() {
124 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
125 ; CHECK-NEXT: Store size: 4 bytes.
126 ; CHECK-NEXT: Variables: dst (4 bytes).
128 %p2i = ptrtoint ptr %dst to i64
129 %i2p = inttoptr i64 %p2i to ptr
130 store i32 0, ptr %i2p, !annotation !0, !dbg !DILocation(scope: !4)
134 ; Emit a remark that reports a store to an alloca through a GEP in an array.
135 define void @store_alloca_gep_array() {
136 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
137 ; CHECK-NEXT: Store size: 4 bytes.
138 ; CHECK-NEXT: Variables: dst (8 bytes).
139 %dst = alloca [2 x i32]
140 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
144 ; Emit a remark that reports a store to an alloca through a bitcast.
145 define void @store_alloca_bitcast() {
146 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
147 ; CHECK-NEXT: Store size: 4 bytes.
148 ; CHECK-NEXT: Variables: dst (4 bytes).
149 %dst = alloca [2 x i16]
150 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
154 ; Emit a remark that reports a store to an alloca that has a DILocalVariable
156 define void @store_alloca_di() {
157 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
158 ; CHECK-NEXT: Store size: 4 bytes.
159 ; CHECK-NEXT: Variables: destination (4 bytes).
161 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
162 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
166 ; Emit a remark that reports a store to an alloca that has more than one
167 ; DILocalVariable attached.
168 define void @store_alloca_di_multiple() {
169 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
170 ; CHECK-NEXT: Store size: 4 bytes.
171 ; CHECK-NEXT: Variables: destination2 (4 bytes), destination (4 bytes).
173 store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
174 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
175 call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
179 ; Emit a remark that reports a store to a PHI node that can be two different
181 define void @store_alloca_phi() {
182 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
183 ; CHECK-NEXT: Store size: 4 bytes.
184 ; CHECK-NEXT: Variables: dst2 (4 bytes), dst (4 bytes).
188 %cmp = icmp eq i32 undef, undef
189 br i1 %cmp, label %l0, label %l1
195 %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
196 store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)
200 ; Emit a remark that reports a store to a PHI node that can be two different
201 ; allocas, where one of it has multiple DILocalVariable.
202 define void @store_alloca_phi_di_multiple() {
203 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
204 ; CHECK-NEXT: Store size: 4 bytes.
205 ; CHECK-NEXT: Variables: dst2 (4 bytes), destination2 (4 bytes), destination (4 bytes).
209 call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
210 call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
211 %cmp = icmp eq i32 undef, undef
212 br i1 %cmp, label %l0, label %l1
218 %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
219 store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)
223 ; Function Attrs: nounwind readnone speculatable willreturn
224 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn
226 !llvm.module.flags = !{!1}
227 !0 = !{ !"auto-init" }
228 !1 = !{i32 2, !"Debug Info Version", i32 3}
229 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
230 !3 = !DIFile(filename: "file", directory: "")
231 !4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
232 !5 = !DIBasicType(name: "int", size: 32)
233 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
234 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)