File: trivial-auto-var-init-store.ll

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 1,998,492 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (235 lines) | stat: -rw-r--r-- 9,232 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
; 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
; RUN: opt --try-experimental-debuginfo-iterators -passes=annotation-remarks -o /dev/null -S -pass-remarks-output=%t.opt.yaml %s -pass-remarks-missed=annotation-remarks 2>&1 | FileCheck %s
; RUN: cat %t.opt.yaml | FileCheck -check-prefix=YAML %s

; Emit a remark that reports a store.
define void @store(ptr %dst) {
; CHECK:      Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; YAML-LABEL: --- !Missed
; YAML-NEXT: Pass:            annotation-remarks
; YAML-NEXT: Name:            AutoInitStore
; YAML-NEXT: DebugLoc:
; YAML-NEXT: Function:        store
; YAML-NEXT: Args:
; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.
; YAML-NEXT:   - String:          "\nStore size: "
; YAML-NEXT:   - StoreSize:       '4'
; YAML-NEXT:   - String:          ' bytes.'
; YAML-NEXT:   - String:          ' Volatile: '
; YAML-NEXT:   - StoreVolatile:       'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT:   - String:          ' Atomic: '
; YAML-NEXT:   - StoreAtomic:       'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT: ...
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a volatile store.
define void @volatile_store(ptr %dst) {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes. Volatile: true.
; YAML-LABEL: --- !Missed
; YAML-NEXT: Pass:            annotation-remarks
; YAML-NEXT: Name:            AutoInitStore
; YAML-NEXT: DebugLoc:
; YAML-NEXT: Function:        volatile_store
; YAML-NEXT: Args:
; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.
; YAML-NEXT:   - String:          "\nStore size: "
; YAML-NEXT:   - StoreSize:       '4'
; YAML-NEXT:   - String:          ' bytes.'
; YAML-NEXT:   - String:          ' Volatile: '
; YAML-NEXT:   - StoreVolatile:       'true'
; YAML-NEXT:   - String:          .
; YAML-NEXT:   - String:          ' Atomic: '
; YAML-NEXT:   - StoreAtomic:       'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT: ...
  store volatile i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports an atomic store.
define void @atomic_store(ptr %dst) {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes. Atomic: true.
; YAML-LABEL: --- !Missed
; YAML-NEXT: Pass:            annotation-remarks
; YAML-NEXT: Name:            AutoInitStore
; YAML-NEXT: DebugLoc:
; YAML-NEXT: Function:        atomic_store
; YAML-NEXT: Args:
; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.
; YAML-NEXT:   - String:          "\nStore size: "
; YAML-NEXT:   - StoreSize:       '4'
; YAML-NEXT:   - String:          ' bytes.'
; YAML-NEXT:   - String:          ' Atomic: '
; YAML-NEXT:   - StoreAtomic:       'true'
; YAML-NEXT:   - String:          .
; YAML-NEXT:   - String:          ' Volatile: '
; YAML-NEXT:   - StoreVolatile:       'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT: ...
  store atomic i32 0, ptr %dst unordered, align 4, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca.
define void @store_alloca() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst (4 bytes).
; YAML-LABEL: --- !Missed
; YAML-NEXT: Pass:            annotation-remarks
; YAML-NEXT: Name:            AutoInitStore
; YAML-NEXT: DebugLoc:
; YAML-NEXT: Function:        store_alloca
; YAML-NEXT: Args:
; YAML-NEXT:   - String:          Store inserted by -ftrivial-auto-var-init.
; YAML-NEXT:   - String:          "\nStore size: "
; YAML-NEXT:   - StoreSize:       '4'
; YAML-NEXT:   - String:          ' bytes.'
; YAML-NEXT:   - String:          "\n Written Variables: "
; YAML-NEXT:   - WVarName:        dst
; YAML-NEXT:   - String:          ' ('
; YAML-NEXT:   - WVarSize:        '4'
; YAML-NEXT:   - String:          ' bytes)'
; YAML-NEXT:   - String:          .
; YAML-NEXT:   - String:          ' Volatile: '
; YAML-NEXT:   - StoreVolatile:    'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT:   - String:          ' Atomic: '
; YAML-NEXT:   - StoreAtomic:     'false'
; YAML-NEXT:   - String:          .
; YAML-NEXT: ...
  %dst = alloca i32
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca through a GEP.
define void @store_alloca_gep() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst (4 bytes).
  %dst = alloca i32
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca through a GEP, with ptrtoint+inttoptr in the way.
define void @store_alloca_gep_inttoptr() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst (4 bytes).
  %dst = alloca i32
  %p2i = ptrtoint ptr %dst to i64
  %i2p = inttoptr i64 %p2i to ptr
  store i32 0, ptr %i2p, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca through a GEP in an array.
define void @store_alloca_gep_array() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst (8 bytes).
  %dst = alloca [2 x i32]
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca through a bitcast.
define void @store_alloca_bitcast() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst (4 bytes).
  %dst = alloca [2 x i16]
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca that has a DILocalVariable
; attached.
define void @store_alloca_di() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: destination (4 bytes).
  %dst = alloca i32
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to an alloca that has more than one
; DILocalVariable attached.
define void @store_alloca_di_multiple() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: destination2 (4 bytes), destination (4 bytes).
  %dst = alloca i32
  store i32 0, ptr %dst, !annotation !0, !dbg !DILocation(scope: !4)
  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
  call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to a PHI node that can be two different
; allocas.
define void @store_alloca_phi() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst2 (4 bytes), dst (4 bytes).
entry:
  %dst = alloca i32
  %dst2 = alloca i32
  %cmp = icmp eq i32 undef, undef
  br i1 %cmp, label %l0, label %l1
l0:
  br label %l2
l1:
  br label %l2
l2:
  %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
  store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Emit a remark that reports a store to a PHI node that can be two different
; allocas, where one of it has multiple DILocalVariable.
define void @store_alloca_phi_di_multiple() {
; CHECK-NEXT: Store inserted by -ftrivial-auto-var-init.
; CHECK-NEXT: Store size: 4 bytes.
; CHECK-NEXT: Variables: dst2 (4 bytes), destination2 (4 bytes), destination (4 bytes).
entry:
  %dst = alloca i32
  %dst2 = alloca i32
  call void @llvm.dbg.declare(metadata ptr %dst, metadata !6, metadata !DIExpression()), !dbg !DILocation(scope: !4)
  call void @llvm.dbg.declare(metadata ptr %dst, metadata !7, metadata !DIExpression()), !dbg !DILocation(scope: !4)
  %cmp = icmp eq i32 undef, undef
  br i1 %cmp, label %l0, label %l1
l0:
  br label %l2
l1:
  br label %l2
l2:
  %phidst = phi ptr [ %dst, %l0 ], [ %dst2, %l1 ]
  store i32 0, ptr %phidst, !annotation !0, !dbg !DILocation(scope: !4)
  ret void
}

; Function Attrs: nounwind readnone speculatable willreturn
declare void @llvm.dbg.declare(metadata, metadata, metadata) nounwind readnone speculatable willreturn

!llvm.module.flags = !{!1}
!0 = !{ !"auto-init" }
!1 = !{i32 2, !"Debug Info Version", i32 3}
!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3)
!3 = !DIFile(filename: "file", directory: "")
!4 = distinct !DISubprogram(name: "function", scope: !3, file: !3, unit: !2)
!5 = !DIBasicType(name: "int", size: 32)
!6 = !DILocalVariable(name: "destination", scope: !4, file: !3, type: !5)
!7 = !DILocalVariable(name: "destination2", scope: !4, file: !3, type: !5)