1
1
;; Test behavior of -optimize-hot-cold-new and related options.
2
2
3
3
;; Check that we don't get hot/cold new calls without enabling it explicitly.
4
- ; RUN: opt < %s -passes=instcombine -S | FileCheck %s --implicit-check-not=hot_cold_t
4
+ ; RUN: opt < %s -passes=instcombine -S | FileCheck %s --check-prefix=OFF
5
+ ; OFF-NOT: hot_cold_t
6
+ ; OFF-LABEL: @new_hot_cold()
5
7
6
8
;; First check with the default cold and hot hint values (255 = -2).
7
- ; RUN: opt < %s -passes=instcombine -optimize-hot-cold-new -S | FileCheck %s --check-prefix=HOTCOLD -DCOLD=1 -DHOT=-2
9
+ ; RUN: opt < %s -passes=instcombine -optimize-hot-cold-new -S | FileCheck %s --check-prefix=HOTCOLD -DCOLD=1 -DHOT=-2 -DPREVHINTCOLD=7 -DPREVHINTNOTCOLD=7 -DPREVHINTHOT=7
8
10
9
11
;; Next check with the non-default cold and hot hint values (200 =-56).
10
- ; RUN: opt < %s -passes=instcombine -optimize-hot-cold-new -cold-new-hint-value=5 -hot-new-hint-value=200 -S | FileCheck %s --check-prefix=HOTCOLD -DCOLD=5 -DHOT=-56
12
+ ; RUN: opt < %s -passes=instcombine -optimize-hot-cold-new -cold-new-hint-value=5 -hot-new-hint-value=200 -S | FileCheck %s --check-prefix=HOTCOLD -DCOLD=5 -DHOT=-56 -DPREVHINTCOLD=7 -DPREVHINTNOTCOLD=7 -DPREVHINTHOT=7
13
+
14
+ ;; Try again with the non-default cold and hot hint values (200 =-56), and this
15
+ ;; time specify that existing hints should be updated.
16
+ ; RUN: opt < %s -passes=instcombine -optimize-hot-cold-new -cold-new-hint-value=5 -notcold-new-hint-value=100 -hot-new-hint-value=200 -optimize-existing-hot-cold-new -S | FileCheck %s --check-prefix=HOTCOLD -DCOLD=5 -DHOT=-56 -DPREVHINTCOLD=5 -DPREVHINTNOTCOLD=100 -DPREVHINTHOT=-56
11
17
12
18
;; Make sure that values not in 0..255 are flagged with an error
13
19
; RUN: not opt < %s -passes=instcombine -optimize-hot-cold-new -cold-new-hint-value=256 -S 2>&1 | FileCheck %s --check-prefix=ERROR
@@ -178,6 +184,162 @@ define void @array_new_align_nothrow() {
178
184
ret void
179
185
}
180
186
187
+ ;; Check that operator new(unsigned long, __hot_cold_t)
188
+ ;; optionally has its hint updated.
189
+ ; HOTCOLD-LABEL: @new_hot_cold()
190
+ define void @new_hot_cold () {
191
+ ;; Attribute cold converted to __hot_cold_t cold value.
192
+ ; HOTCOLD: @_Znwm12__hot_cold_t(i64 10, i8 [[PREVHINTCOLD]])
193
+ %call = call ptr @_Znwm12__hot_cold_t (i64 10 , i8 7 ) #0
194
+ call void @dummy (ptr %call )
195
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
196
+ ; HOTCOLD: @_Znwm12__hot_cold_t(i64 10, i8 [[PREVHINTNOTCOLD]])
197
+ %call1 = call ptr @_Znwm12__hot_cold_t (i64 10 , i8 7 ) #1
198
+ call void @dummy (ptr %call1 )
199
+ ;; Attribute hot converted to __hot_cold_t hot value.
200
+ ; HOTCOLD: @_Znwm12__hot_cold_t(i64 10, i8 [[PREVHINTHOT]])
201
+ %call2 = call ptr @_Znwm12__hot_cold_t (i64 10 , i8 7 ) #2
202
+ call void @dummy (ptr %call2 )
203
+ ret void
204
+ }
205
+
206
+ ;; Check that operator new(unsigned long, std::align_val_t, __hot_cold_t)
207
+ ;; optionally has its hint updated.
208
+ ; HOTCOLD-LABEL: @new_align_hot_cold()
209
+ define void @new_align_hot_cold () {
210
+ ;; Attribute cold converted to __hot_cold_t cold value.
211
+ ; HOTCOLD: @_ZnwmSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTCOLD]])
212
+ %call = call ptr @_ZnwmSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #0
213
+ call void @dummy (ptr %call )
214
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
215
+ ; HOTCOLD: @_ZnwmSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTNOTCOLD]])
216
+ %call1 = call ptr @_ZnwmSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #1
217
+ call void @dummy (ptr %call1 )
218
+ ;; Attribute hot converted to __hot_cold_t hot value.
219
+ ; HOTCOLD: @_ZnwmSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTHOT]])
220
+ %call2 = call ptr @_ZnwmSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #2
221
+ call void @dummy (ptr %call2 )
222
+ ret void
223
+ }
224
+
225
+ ;; Check that operator new(unsigned long, const std::nothrow_t&, __hot_cold_t)
226
+ ;; optionally has its hint updated.
227
+ ; HOTCOLD-LABEL: @new_nothrow_hot_cold()
228
+ define void @new_nothrow_hot_cold () {
229
+ %nt = alloca i8
230
+ ;; Attribute cold converted to __hot_cold_t cold value.
231
+ ; HOTCOLD: @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTCOLD]])
232
+ %call = call ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #0
233
+ call void @dummy (ptr %call )
234
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
235
+ ; HOTCOLD: @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTNOTCOLD]])
236
+ %call1 = call ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #1
237
+ call void @dummy (ptr %call1 )
238
+ ;; Attribute hot converted to __hot_cold_t hot value.
239
+ ; HOTCOLD: @_ZnwmRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTHOT]])
240
+ %call2 = call ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #2
241
+ call void @dummy (ptr %call2 )
242
+ ret void
243
+ }
244
+
245
+ ;; Check that operator new(unsigned long, std::align_val_t, const std::nothrow_t&, __hot_cold_t)
246
+ ;; optionally has its hint updated.
247
+ ; HOTCOLD-LABEL: @new_align_nothrow_hot_cold()
248
+ define void @new_align_nothrow_hot_cold () {
249
+ %nt = alloca i8
250
+ ;; Attribute cold converted to __hot_cold_t cold value.
251
+ ; HOTCOLD: @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTCOLD]])
252
+ %call = call ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #0
253
+ call void @dummy (ptr %call )
254
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
255
+ ; HOTCOLD: @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTNOTCOLD]])
256
+ %call1 = call ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #1
257
+ call void @dummy (ptr %call1 )
258
+ ;; Attribute hot converted to __hot_cold_t hot value.
259
+ ; HOTCOLD: @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTHOT]])
260
+ %call2 = call ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #2
261
+ call void @dummy (ptr %call2 )
262
+ ret void
263
+ }
264
+
265
+ ;; Check that operator new[](unsigned long, __hot_cold_t)
266
+ ;; optionally has its hint updated.
267
+ ; HOTCOLD-LABEL: @array_new_hot_cold()
268
+ define void @array_new_hot_cold () {
269
+ ;; Attribute cold converted to __hot_cold_t cold value.
270
+ ; HOTCOLD: @_Znam12__hot_cold_t(i64 10, i8 [[PREVHINTCOLD]])
271
+ %call = call ptr @_Znam12__hot_cold_t (i64 10 , i8 7 ) #0
272
+ call void @dummy (ptr %call )
273
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
274
+ ; HOTCOLD: @_Znam12__hot_cold_t(i64 10, i8 [[PREVHINTNOTCOLD]])
275
+ %call1 = call ptr @_Znam12__hot_cold_t (i64 10 , i8 7 ) #1
276
+ call void @dummy (ptr %call1 )
277
+ ;; Attribute hot converted to __hot_cold_t hot value.
278
+ ; HOTCOLD: @_Znam12__hot_cold_t(i64 10, i8 [[PREVHINTHOT]])
279
+ %call2 = call ptr @_Znam12__hot_cold_t (i64 10 , i8 7 ) #2
280
+ call void @dummy (ptr %call2 )
281
+ ret void
282
+ }
283
+
284
+ ;; Check that operator new[](unsigned long, std::align_val_t, __hot_cold_t)
285
+ ;; optionally has its hint updated.
286
+ ; HOTCOLD-LABEL: @array_new_align_hot_cold()
287
+ define void @array_new_align_hot_cold () {
288
+ ;; Attribute cold converted to __hot_cold_t cold value.
289
+ ; HOTCOLD: @_ZnamSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTCOLD]])
290
+ %call = call ptr @_ZnamSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #0
291
+ call void @dummy (ptr %call )
292
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
293
+ ; HOTCOLD: @_ZnamSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTNOTCOLD]])
294
+ %call1 = call ptr @_ZnamSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #1
295
+ call void @dummy (ptr %call1 )
296
+ ;; Attribute hot converted to __hot_cold_t hot value.
297
+ ; HOTCOLD: @_ZnamSt11align_val_t12__hot_cold_t(i64 10, i64 8, i8 [[PREVHINTHOT]])
298
+ %call2 = call ptr @_ZnamSt11align_val_t12__hot_cold_t (i64 10 , i64 8 , i8 7 ) #2
299
+ call void @dummy (ptr %call2 )
300
+ ret void
301
+ }
302
+
303
+ ;; Check that operator new[](unsigned long, const std::nothrow_t&, __hot_cold_t)
304
+ ;; optionally has its hint updated.
305
+ ; HOTCOLD-LABEL: @array_new_nothrow_hot_cold()
306
+ define void @array_new_nothrow_hot_cold () {
307
+ %nt = alloca i8
308
+ ;; Attribute cold converted to __hot_cold_t cold value.
309
+ ; HOTCOLD: @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTCOLD]])
310
+ %call = call ptr @_ZnamRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #0
311
+ call void @dummy (ptr %call )
312
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
313
+ ; HOTCOLD: @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTNOTCOLD]])
314
+ %call1 = call ptr @_ZnamRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #1
315
+ call void @dummy (ptr %call1 )
316
+ ;; Attribute hot converted to __hot_cold_t hot value.
317
+ ; HOTCOLD: @_ZnamRKSt9nothrow_t12__hot_cold_t(i64 10, ptr nonnull %nt, i8 [[PREVHINTHOT]])
318
+ %call2 = call ptr @_ZnamRKSt9nothrow_t12__hot_cold_t (i64 10 , ptr %nt , i8 7 ) #2
319
+ call void @dummy (ptr %call2 )
320
+ ret void
321
+ }
322
+
323
+ ;; Check that operator new[](unsigned long, std::align_val_t, const std::nothrow_t&, __hot_cold_t)
324
+ ;; optionally has its hint updated.
325
+ ; HOTCOLD-LABEL: @array_new_align_nothrow_hot_cold()
326
+ define void @array_new_align_nothrow_hot_cold () {
327
+ %nt = alloca i8
328
+ ;; Attribute cold converted to __hot_cold_t cold value.
329
+ ; HOTCOLD: @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTCOLD]])
330
+ %call = call ptr @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #0
331
+ call void @dummy (ptr %call )
332
+ ;; Attribute notcold converted to __hot_cold_t notcold value.
333
+ ; HOTCOLD: @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTNOTCOLD]])
334
+ %call1 = call ptr @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #1
335
+ call void @dummy (ptr %call1 )
336
+ ;; Attribute hot converted to __hot_cold_t hot value.
337
+ ; HOTCOLD: @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t(i64 10, i64 8, ptr nonnull %nt, i8 [[PREVHINTHOT]])
338
+ %call2 = call ptr @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 10 , i64 8 , ptr %nt , i8 7 ) #2
339
+ call void @dummy (ptr %call2 )
340
+ ret void
341
+ }
342
+
181
343
;; So that instcombine doesn't optimize out the call.
182
344
declare void @dummy (ptr )
183
345
@@ -189,6 +351,14 @@ declare ptr @_Znam(i64)
189
351
declare ptr @_ZnamSt11align_val_t (i64 , i64 )
190
352
declare ptr @_ZnamRKSt9nothrow_t (i64 , ptr )
191
353
declare ptr @_ZnamSt11align_val_tRKSt9nothrow_t (i64 , i64 , ptr )
354
+ declare ptr @_Znwm12__hot_cold_t (i64 , i8 )
355
+ declare ptr @_ZnwmSt11align_val_t12__hot_cold_t (i64 , i64 , i8 )
356
+ declare ptr @_ZnwmRKSt9nothrow_t12__hot_cold_t (i64 , ptr , i8 )
357
+ declare ptr @_ZnwmSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 , i64 , ptr , i8 )
358
+ declare ptr @_Znam12__hot_cold_t (i64 , i8 )
359
+ declare ptr @_ZnamSt11align_val_t12__hot_cold_t (i64 , i64 , i8 )
360
+ declare ptr @_ZnamRKSt9nothrow_t12__hot_cold_t (i64 , ptr , i8 )
361
+ declare ptr @_ZnamSt11align_val_tRKSt9nothrow_t12__hot_cold_t (i64 , i64 , ptr , i8 )
192
362
193
363
attributes #0 = { builtin allocsize(0 ) "memprof" ="cold" }
194
364
attributes #1 = { builtin allocsize(0 ) "memprof" ="notcold" }
0 commit comments