1 ; RUN: opt -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(i32* %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, i32* %dst, !annotation !0, !dbg !DILocation(scope: !4)
29 ; Emit a remark that reports a volatile store.
30 define void @volatile_store(i32* %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, i32* %dst, !annotation !0, !dbg !DILocation(scope: !4)
54 ; Emit a remark that reports an atomic store.
55 define void @atomic_store(i32* %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, i32* %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, i32* %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 %gep = getelementptr i32, i32* %dst, i32 0
119 store i32 0, i32* %gep, !annotation !0, !dbg !DILocation(scope: !4)
123 ; Emit a remark that reports a store to an alloca through a GEP, with ptrtoint+inttoptr in the way.
124 define void @store_alloca_gep_inttoptr() {
125 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
126 ; CHECK-NEXT: Store size: 4 bytes.
127 ; CHECK-NEXT: Variables: dst (4 bytes).
129 %gep = getelementptr i32, i32* %dst, i32 0
130 %p2i = ptrtoint i32* %gep to i64
131 %i2p = inttoptr i64 %p2i to i32*
132 store i32 0, i32* %i2p, !annotation !0, !dbg !DILocation(scope: !4)
136 ; Emit a remark that reports a store to an alloca through a GEP in an array.
137 define void @store_alloca_gep_array() {
138 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
139 ; CHECK-NEXT: Store size: 4 bytes.
140 ; CHECK-NEXT: Variables: dst (8 bytes).
141 %dst = alloca [2 x i32]
142 %gep = getelementptr [2 x i32], [2 x i32]* %dst, i64 0, i64 0
143 store i32 0, i32* %gep, !annotation !0, !dbg !DILocation(scope: !4)
147 ; Emit a remark that reports a store to an alloca through a bitcast.
148 define void @store_alloca_bitcast() {
149 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
150 ; CHECK-NEXT: Store size: 4 bytes.
151 ; CHECK-NEXT: Variables: dst (4 bytes).
152 %dst = alloca [2 x i16]
153 %bc = bitcast [2 x i16]* %dst to i32*
154 store i32 0, i32* %bc, !annotation !0, !dbg !DILocation(scope: !4)
158 ; Emit a remark that reports a store to an alloca that has a DILocalVariable
160 define void @store_alloca_di() {
161 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
162 ; CHECK-NEXT: Store size: 4 bytes.
163 ; CHECK-NEXT: Variables: destination (4 bytes).
165 store i32 0, i32* %dst, !annotation !0, !dbg !DILocation(scope: !4)
166 call void @llvm.dbg.declare(metadata i32* %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
170 ; Emit a remark that reports a store to an alloca that has more than one
171 ; DILocalVariable attached.
172 define void @store_alloca_di_multiple() {
173 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
174 ; CHECK-NEXT: Store size: 4 bytes.
175 ; CHECK-NEXT: Variables: destination2 (4 bytes), destination (4 bytes).
177 store i32 0, i32* %dst, !annotation !0, !dbg !DILocation(scope: !4)
178 call void @llvm.dbg.declare(metadata i32* %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
179 call void @llvm.dbg.declare(metadata i32* %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
183 ; Emit a remark that reports a store to a PHI node that can be two different
185 define void @store_alloca_phi() {
186 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
187 ; CHECK-NEXT: Store size: 4 bytes.
188 ; CHECK-NEXT: Variables: dst2 (4 bytes), dst (4 bytes).
192 %cmp = icmp eq i32 undef, undef
193 br i1 %cmp, label %l0, label %l1
199 %phidst = phi i32* [ %dst, %l0 ], [ %dst2, %l1 ]
200 store i32 0, i32* %phidst, !annotation !0, !dbg !DILocation(scope: !4)
204 ; Emit a remark that reports a store to a PHI node that can be two different
205 ; allocas, where one of it has multiple DILocalVariable.
206 define void @store_alloca_phi_di_multiple() {
207 ; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
208 ; CHECK-NEXT: Store size: 4 bytes.
209 ; CHECK-NEXT: Variables: dst2 (4 bytes), destination2 (4 bytes), destination (4 bytes).
213 call void @llvm.dbg.declare(metadata i32* %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
214 call void @llvm.dbg.declare(metadata i32* %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
215 %cmp = icmp eq i32 undef, undef
216 br i1 %cmp, label %l0, label %l1
222 %phidst = phi i32* [ %dst, %l0 ], [ %dst2, %l1 ]
223 store i32 0, i32* %phidst, !annotation !0, !dbg !DILocation(scope: !4)
227 ; Function Attrs: nounwind readnone speculatable willreturn
228 declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn
230 !llvm.module.flags = !{!1}
231 !0 = !{ !"auto-init" }
232 !1 = !{i32 2, !"Debug Info Version", i32 3}
233 !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
234 !3 = !DIFile(filename: "file", directory: "")
235 !4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
236 !5 = !DIBasicType(name: "int", size: 32)
237 !6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
238 !7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)