1 ;; Tests memprof profile matching (with and without instrumentation profiles).
3 ;; Several requirements due to using raw profile inputs:
4 ;; PGO profile uses zlib compression
6 ;; Avoid failures on big-endian systems that can't read the profile properly
7 ; REQUIRES: x86_64-linux
8 ;; -stats requires asserts
11 ;; TODO: Use text profile inputs once that is available for memprof.
12 ;; # To update the Inputs below, run Inputs/update_memprof_inputs.sh.
13 ;; # To generate below LLVM IR for use in matching:
14 ;; $ clang++ -gmlt -fdebug-info-for-profiling -fno-omit-frame-pointer \
15 ;; -fno-optimize-sibling-calls memprof.cc -S -emit-llvm
17 ;; Generate indexed profiles of all combinations:
18 ; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
19 ; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.pgomemprofdata
20 ; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext -o %t.pgoprofdata
21 ; RUN: llvm-profdata merge %S/Inputs/memprof.nocolinfo.memprofraw --profiled-binary %S/Inputs/memprof.nocolinfo.exe -o %t.nocolinfo.memprofdata
23 ;; In all below cases we should not get any messages about missing profile data
24 ;; for any functions. Either we are not performing any matching for a particular
25 ;; profile type or we are performing the matching and it should be successful.
26 ; ALL-NOT: memprof record not found for function hash
27 ; ALL-NOT: no profile data available for function
29 ;; Using a memprof-only profile for memprof-use should only give memprof metadata
30 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,MEMPROFMATCHINFO,MEMPROFSTATS
31 ; There should not be any PGO metadata
32 ; MEMPROFONLY-NOT: !prof
34 ;; Try again but using a profile with missing columns. The memprof matcher
35 ;; should recognize that there are no non-zero columns in the profile and
36 ;; not attempt to include column numbers in the matching (which means that the
37 ;; stack ids will be different).
38 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY
40 ;; Test the same thing but by passing the memory profile through to a default
41 ;; pipeline via -memory-profile-file=, which should cause the necessary field
42 ;; of the PGOOptions structure to be populated with the profile filename.
43 ; RUN: opt < %s -passes='default<O2>' -memory-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
45 ;; Using a pgo+memprof profile for memprof-use should only give memprof metadata
46 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY
48 ;; Using a pgo-only profile for memprof-use should give an error
49 ; RUN: not opt < %s -passes='memprof-use<profile-filename=%t.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY
50 ; MEMPROFWITHPGOONLY: Not a memory profile
52 ;; Using a memprof-only profile for pgo-instr-use should give an error
53 ; RUN: not opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY
54 ; PGOWITHMEMPROFONLY: Not an IR level instrumentation profile
56 ;; Using a pgo+memprof profile for pgo-instr-use should only give pgo metadata
57 ; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=PGO,ALL,PGOONLY
58 ; There should not be any memprof related metadata
59 ; PGOONLY-NOT: !memprof
60 ; PGOONLY-NOT: !callsite
62 ;; Using a pgo+memprof profile for both memprof-use and pgo-instr-use should
63 ;; give both memprof and pgo metadata.
64 ; RUN: opt < %s -passes='pgo-instr-use,memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-test-profile-file=%t.pgomemprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,PGO
66 ;; Check that the total sizes are reported if requested.
67 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES
69 ;; Make sure we emit a random hotness seed if requested.
70 ; RUN: llvm-profdata merge -memprof-random-hotness %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand 2>&1 | FileCheck %s --check-prefix=RAND
71 ; RAND: random hotness seed =
72 ;; Can't check the exact values, but make sure applying the random profile
73 ;; succeeds with the same stats
74 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS
76 ;; Make sure we use a specific random hotness seed if requested.
77 ; RUN: llvm-profdata merge -memprof-random-hotness -memprof-random-hotness-seed=1730170724 %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdatarand2 2>&1 | FileCheck %s --check-prefix=RAND2
78 ; RAND2: random hotness seed = 1730170724
79 ; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand2>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=MEMPROFRAND2,ALL,MEMPROFONLY,MEMPROFSTATS
81 ; MEMPROFMATCHINFO: MemProf notcold context with id 1093248920606587996 has total profiled size 10 is matched
82 ; MEMPROFMATCHINFO: MemProf notcold context with id 5725971306423925017 has total profiled size 10 is matched
83 ; MEMPROFMATCHINFO: MemProf notcold context with id 6792096022461663180 has total profiled size 10 is matched
84 ; MEMPROFMATCHINFO: MemProf cold context with id 8525406123785421946 has total profiled size 10 is matched
85 ; MEMPROFMATCHINFO: MemProf cold context with id 11714230664165068698 has total profiled size 10 is matched
86 ; MEMPROFMATCHINFO: MemProf cold context with id 15737101490731057601 has total profiled size 10 is matched
87 ; MEMPROFMATCHINFO: MemProf cold context with id 16342802530253093571 has total profiled size 10 is matched
88 ; MEMPROFMATCHINFO: MemProf cold context with id 18254812774972004394 has total profiled size 10 is matched
90 ; ModuleID = 'memprof.cc'
91 source_filename = "memprof.cc"
92 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
93 target triple = "x86_64-unknown-linux-gnu"
95 ; Function Attrs: mustprogress noinline optnone uwtable
96 ; ALL-LABEL: define dso_local noundef{{.*}}ptr @_Z3foov()
97 ; There should be some PGO metadata
99 define dso_local noundef ptr @_Z3foov() #0 !dbg !10 {
101 ; MEMPROF: call {{.*}} @_Znam{{.*}} !memprof ![[M1:[0-9]+]], !callsite ![[C1:[0-9]+]]
102 ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} !memprof ![[M1:[0-9]+]], !callsite ![[C1:[0-9]+]]
103 %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !13
104 ret ptr %call, !dbg !14
107 ; Function Attrs: nobuiltin allocsize(0)
108 declare noundef nonnull ptr @_Znam(i64 noundef) #1
110 ; Function Attrs: mustprogress noinline optnone uwtable
111 ; ALL-LABEL: define dso_local noundef{{.*}}ptr @_Z4foo2v()
112 define dso_local noundef ptr @_Z4foo2v() #0 !dbg !15 {
114 ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C2:[0-9]+]]
115 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C2:[0-9]+]]
116 %call = call noundef ptr @_Z3foov(), !dbg !16
117 ret ptr %call, !dbg !17
120 ; Function Attrs: mustprogress noinline optnone uwtable
121 define dso_local noundef ptr @_Z3barv() #0 !dbg !18 {
123 ; MEMPROF: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C3:[0-9]+]]
124 ; MEMPROFNOCOLINFO: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C3:[0-9]+]]
125 %call = call noundef ptr @_Z4foo2v(), !dbg !19
126 ret ptr %call, !dbg !20
129 ; Function Attrs: mustprogress noinline optnone uwtable
130 define dso_local noundef ptr @_Z3bazv() #0 !dbg !21 {
132 ; MEMPROF: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C4:[0-9]+]]
133 ; MEMPROFNOCOLINFO: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C4:[0-9]+]]
134 %call = call noundef ptr @_Z4foo2v(), !dbg !22
135 ret ptr %call, !dbg !23
138 ; Function Attrs: mustprogress noinline optnone uwtable
139 define dso_local noundef ptr @_Z7recursej(i32 noundef %n) #0 !dbg !24 {
141 %retval = alloca ptr, align 8
142 %n.addr = alloca i32, align 4
143 store i32 %n, ptr %n.addr, align 4
144 %0 = load i32, ptr %n.addr, align 4, !dbg !25
145 %tobool = icmp ne i32 %0, 0, !dbg !25
146 br i1 %tobool, label %if.end, label %if.then, !dbg !26
148 if.then: ; preds = %entry
149 ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C5:[0-9]+]]
150 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C5:[0-9]+]]
151 %call = call noundef ptr @_Z3foov(), !dbg !27
152 store ptr %call, ptr %retval, align 8, !dbg !28
153 br label %return, !dbg !28
155 if.end: ; preds = %entry
156 %1 = load i32, ptr %n.addr, align 4, !dbg !29
157 %sub = sub i32 %1, 1, !dbg !30
158 ; MEMPROF: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C6:[0-9]+]]
159 ; MEMPROFNOCOLINFO: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C6:[0-9]+]]
160 %call1 = call noundef ptr @_Z7recursej(i32 noundef %sub), !dbg !31
161 store ptr %call1, ptr %retval, align 8, !dbg !32
162 br label %return, !dbg !32
164 return: ; preds = %if.end, %if.then
165 %2 = load ptr, ptr %retval, align 8, !dbg !33
169 ; Function Attrs: mustprogress noinline norecurse optnone uwtable
170 define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) #2 !dbg !34 {
172 %retval = alloca i32, align 4
173 %argc.addr = alloca i32, align 4
174 %argv.addr = alloca ptr, align 8
175 %a = alloca ptr, align 8
176 %b = alloca ptr, align 8
177 %c = alloca ptr, align 8
178 %d = alloca ptr, align 8
179 %e = alloca ptr, align 8
180 %f = alloca ptr, align 8
181 %i = alloca i32, align 4
182 %g = alloca ptr, align 8
183 store i32 0, ptr %retval, align 4
184 store i32 %argc, ptr %argc.addr, align 4
185 store ptr %argv, ptr %argv.addr, align 8
186 ; MEMPROF: call {{.*}} @_Znam{{.*}} #[[A1:[0-9]+]]
187 ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} #[[A1:[0-9]+]]
188 %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !35
189 store ptr %call, ptr %a, align 8, !dbg !36
190 ; MEMPROF: call {{.*}} @_Znam{{.*}} #[[A2:[0-9]+]]
191 ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} #[[A2:[0-9]+]]
192 %call1 = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !37
193 store ptr %call1, ptr %b, align 8, !dbg !38
194 ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C7:[0-9]+]]
195 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C7:[0-9]+]]
196 %call2 = call noundef ptr @_Z3foov(), !dbg !39
197 store ptr %call2, ptr %c, align 8, !dbg !40
198 ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C8:[0-9]+]]
199 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C8:[0-9]+]]
200 %call3 = call noundef ptr @_Z3foov(), !dbg !41
201 store ptr %call3, ptr %d, align 8, !dbg !42
202 ; MEMPROF: call {{.*}} @_Z3barv{{.*}} !callsite ![[C9:[0-9]+]]
203 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3barv{{.*}} !callsite ![[C9:[0-9]+]]
204 %call4 = call noundef ptr @_Z3barv(), !dbg !43
205 store ptr %call4, ptr %e, align 8, !dbg !44
206 ; MEMPROF: call {{.*}} @_Z3bazv{{.*}} !callsite ![[C10:[0-9]+]]
207 ; MEMPROFNOCOLINFO: call {{.*}} @_Z3bazv{{.*}} !callsite ![[C10:[0-9]+]]
208 %call5 = call noundef ptr @_Z3bazv(), !dbg !45
209 store ptr %call5, ptr %f, align 8, !dbg !46
210 %0 = load ptr, ptr %a, align 8, !dbg !47
211 call void @llvm.memset.p0.i64(ptr align 1 %0, i8 0, i64 10, i1 false), !dbg !48
212 %1 = load ptr, ptr %b, align 8, !dbg !49
213 call void @llvm.memset.p0.i64(ptr align 1 %1, i8 0, i64 10, i1 false), !dbg !50
214 %2 = load ptr, ptr %c, align 8, !dbg !51
215 call void @llvm.memset.p0.i64(ptr align 1 %2, i8 0, i64 10, i1 false), !dbg !52
216 %3 = load ptr, ptr %d, align 8, !dbg !53
217 call void @llvm.memset.p0.i64(ptr align 1 %3, i8 0, i64 10, i1 false), !dbg !54
218 %4 = load ptr, ptr %e, align 8, !dbg !55
219 call void @llvm.memset.p0.i64(ptr align 1 %4, i8 0, i64 10, i1 false), !dbg !56
220 %5 = load ptr, ptr %f, align 8, !dbg !57
221 call void @llvm.memset.p0.i64(ptr align 1 %5, i8 0, i64 10, i1 false), !dbg !58
222 %6 = load ptr, ptr %a, align 8, !dbg !59
223 %isnull = icmp eq ptr %6, null, !dbg !60
224 br i1 %isnull, label %delete.end, label %delete.notnull, !dbg !60
226 delete.notnull: ; preds = %entry
227 call void @_ZdaPv(ptr noundef %6) #7, !dbg !61
228 br label %delete.end, !dbg !61
230 delete.end: ; preds = %delete.notnull, %entry
231 %7 = load ptr, ptr %c, align 8, !dbg !63
232 %isnull6 = icmp eq ptr %7, null, !dbg !64
233 br i1 %isnull6, label %delete.end8, label %delete.notnull7, !dbg !64
235 delete.notnull7: ; preds = %delete.end
236 call void @_ZdaPv(ptr noundef %7) #7, !dbg !65
237 br label %delete.end8, !dbg !65
239 delete.end8: ; preds = %delete.notnull7, %delete.end
240 %call9 = call i32 @sleep(i32 noundef 200), !dbg !66
241 %8 = load ptr, ptr %b, align 8, !dbg !67
242 %isnull10 = icmp eq ptr %8, null, !dbg !68
243 br i1 %isnull10, label %delete.end12, label %delete.notnull11, !dbg !68
245 delete.notnull11: ; preds = %delete.end8
246 call void @_ZdaPv(ptr noundef %8) #7, !dbg !69
247 br label %delete.end12, !dbg !69
249 delete.end12: ; preds = %delete.notnull11, %delete.end8
250 %9 = load ptr, ptr %d, align 8, !dbg !70
251 %isnull13 = icmp eq ptr %9, null, !dbg !71
252 br i1 %isnull13, label %delete.end15, label %delete.notnull14, !dbg !71
254 delete.notnull14: ; preds = %delete.end12
255 call void @_ZdaPv(ptr noundef %9) #7, !dbg !72
256 br label %delete.end15, !dbg !72
258 delete.end15: ; preds = %delete.notnull14, %delete.end12
259 %10 = load ptr, ptr %e, align 8, !dbg !73
260 %isnull16 = icmp eq ptr %10, null, !dbg !74
261 br i1 %isnull16, label %delete.end18, label %delete.notnull17, !dbg !74
263 delete.notnull17: ; preds = %delete.end15
264 call void @_ZdaPv(ptr noundef %10) #7, !dbg !75
265 br label %delete.end18, !dbg !75
267 delete.end18: ; preds = %delete.notnull17, %delete.end15
268 %11 = load ptr, ptr %f, align 8, !dbg !76
269 %isnull19 = icmp eq ptr %11, null, !dbg !77
270 br i1 %isnull19, label %delete.end21, label %delete.notnull20, !dbg !77
272 delete.notnull20: ; preds = %delete.end18
273 call void @_ZdaPv(ptr noundef %11) #7, !dbg !78
274 br label %delete.end21, !dbg !78
276 delete.end21: ; preds = %delete.notnull20, %delete.end18
277 store i32 0, ptr %i, align 4, !dbg !79
278 br label %for.cond, !dbg !80
280 for.cond: ; preds = %for.inc, %delete.end21
281 %12 = load i32, ptr %i, align 4, !dbg !81
282 %cmp = icmp ult i32 %12, 2, !dbg !82
283 br i1 %cmp, label %for.body, label %for.end, !dbg !83
285 for.body: ; preds = %for.cond
286 %13 = load i32, ptr %i, align 4, !dbg !84
287 %add = add i32 %13, 3, !dbg !85
288 ; MEMPROF: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C11:[0-9]+]]
289 ; MEMPROFNOCOLINFO: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C11:[0-9]+]]
290 %call22 = call noundef ptr @_Z7recursej(i32 noundef %add), !dbg !86
291 store ptr %call22, ptr %g, align 8, !dbg !87
292 %14 = load ptr, ptr %g, align 8, !dbg !88
293 call void @llvm.memset.p0.i64(ptr align 1 %14, i8 0, i64 10, i1 false), !dbg !89
294 %15 = load i32, ptr %i, align 4, !dbg !90
295 %tobool = icmp ne i32 %15, 0, !dbg !90
296 br i1 %tobool, label %if.end, label %if.then, !dbg !91
298 if.then: ; preds = %for.body
299 %call23 = call i32 @sleep(i32 noundef 200), !dbg !92
300 br label %if.end, !dbg !92
302 if.end: ; preds = %if.then, %for.body
303 %16 = load ptr, ptr %g, align 8, !dbg !93
304 %isnull24 = icmp eq ptr %16, null, !dbg !94
305 br i1 %isnull24, label %delete.end26, label %delete.notnull25, !dbg !94
307 delete.notnull25: ; preds = %if.end
308 call void @_ZdaPv(ptr noundef %16) #7, !dbg !95
309 br label %delete.end26, !dbg !95
311 delete.end26: ; preds = %delete.notnull25, %if.end
312 br label %for.inc, !dbg !96
314 for.inc: ; preds = %delete.end26
315 %17 = load i32, ptr %i, align 4, !dbg !97
316 %inc = add i32 %17, 1, !dbg !97
317 store i32 %inc, ptr %i, align 4, !dbg !97
318 br label %for.cond, !dbg !99, !llvm.loop !100
320 for.end: ; preds = %for.cond
324 ; MEMPROF: #[[A1]] = { builtin allocsize(0) "memprof"="notcold" }
325 ; MEMPROF: #[[A2]] = { builtin allocsize(0) "memprof"="cold" }
326 ; MEMPROF: ![[M1]] = !{![[MIB1:[0-9]+]], ![[MIB2:[0-9]+]], ![[MIB3:[0-9]+]], ![[MIB4:[0-9]+]], ![[MIB5:[0-9]+]]}
327 ; MEMPROF: ![[MIB1]] = !{![[STACK1:[0-9]+]], !"cold"}
328 ; MEMPROF: ![[STACK1]] = !{i64 2732490490862098848, i64 748269490701775343}
329 ; MEMPROF: ![[MIB2]] = !{![[STACK2:[0-9]+]], !"cold"}
330 ; MEMPROF: ![[STACK2]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 1544787832369987002}
331 ; MEMPROF: ![[MIB3]] = !{![[STACK3:[0-9]+]], !"notcold"}
332 ; MEMPROF: ![[STACK3]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934}
333 ; MEMPROF: ![[MIB4]] = !{![[STACK4:[0-9]+]], !"cold"}
334 ; MEMPROF: ![[STACK4]] = !{i64 2732490490862098848, i64 8467819354083268568}
335 ; MEMPROF: ![[MIB5]] = !{![[STACK5:[0-9]+]], !"notcold"}
336 ; MEMPROF: ![[STACK5]] = !{i64 2732490490862098848, i64 8690657650969109624}
337 ; MEMPROF: ![[C1]] = !{i64 2732490490862098848}
338 ; MEMPROF: ![[C2]] = !{i64 8467819354083268568}
339 ; MEMPROF: ![[C3]] = !{i64 9086428284934609951}
340 ; MEMPROF: ![[C4]] = !{i64 -5964873800580613432}
341 ; MEMPROF: ![[C5]] = !{i64 2104812325165620841}
342 ; MEMPROF: ![[C6]] = !{i64 6281715513834610934}
343 ; MEMPROF: ![[C7]] = !{i64 8690657650969109624}
344 ; MEMPROF: ![[C8]] = !{i64 748269490701775343}
345 ; MEMPROF: ![[C9]] = !{i64 -5747251260480066785}
346 ; MEMPROF: ![[C10]] = !{i64 2061451396820446691}
347 ; MEMPROF: ![[C11]] = !{i64 1544787832369987002}
349 ;; For non-context sensitive allocations that get attributes we emit a message
350 ;; with the full allocation context hash, type, and size in bytes.
351 ; TOTALSIZES: Total size for full allocation context hash 6792096022461663180 and single alloc type notcold: 10
352 ; TOTALSIZES: Total size for full allocation context hash 15737101490731057601 and single alloc type cold: 10
353 ;; For context sensitive allocations the full context hash and size in bytes
354 ;; are in separate metadata nodes included on the MIB metadata.
355 ; TOTALSIZES: !"cold", ![[CONTEXT1:[0-9]+]]}
356 ; TOTALSIZES: ![[CONTEXT1]] = !{i64 8525406123785421946, i64 10}
357 ; TOTALSIZES: !"cold", ![[CONTEXT2:[0-9]+]]}
358 ; TOTALSIZES: ![[CONTEXT2]] = !{i64 -6732513409544482918, i64 10}
359 ; TOTALSIZES: !"notcold", ![[CONTEXT3:[0-9]+]]}
360 ; TOTALSIZES: ![[CONTEXT3]] = !{i64 5725971306423925017, i64 10}
361 ;; There can be more than one context id / size pair due to context trimming
363 ; TOTALSIZES: !"cold", ![[CONTEXT4:[0-9]+]], ![[CONTEXT5:[0-9]+]]}
364 ; TOTALSIZES: ![[CONTEXT4]] = !{i64 -2103941543456458045, i64 10}
365 ; TOTALSIZES: ![[CONTEXT5]] = !{i64 -191931298737547222, i64 10}
366 ; TOTALSIZES: !"notcold", ![[CONTEXT6:[0-9]+]]}
367 ; TOTALSIZES: ![[CONTEXT6]] = !{i64 1093248920606587996, i64 10}
369 ; MEMPROFNOCOLINFO: #[[A1]] = { builtin allocsize(0) "memprof"="notcold" }
370 ; MEMPROFNOCOLINFO: #[[A2]] = { builtin allocsize(0) "memprof"="cold" }
371 ; MEMPROFNOCOLINFO: ![[M1]] = !{![[MIB1:[0-9]+]], ![[MIB2:[0-9]+]], ![[MIB3:[0-9]+]], ![[MIB4:[0-9]+]], ![[MIB5:[0-9]+]]}
372 ; MEMPROFNOCOLINFO: ![[MIB1]] = !{![[STACK1:[0-9]+]], !"cold"}
373 ; MEMPROFNOCOLINFO: ![[STACK1]] = !{i64 5281664982037379640, i64 6362220161075421157, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790, i64 3577763375057267810}
374 ; MEMPROFNOCOLINFO: ![[MIB2]] = !{![[STACK2:[0-9]+]], !"notcold"}
375 ; MEMPROFNOCOLINFO: ![[STACK2]] = !{i64 5281664982037379640, i64 6362220161075421157, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790}
376 ; MEMPROFNOCOLINFO: ![[MIB3]] = !{![[STACK3:[0-9]+]], !"notcold"}
377 ; MEMPROFNOCOLINFO: ![[STACK3]] = !{i64 5281664982037379640, i64 -6896091699916449732}
378 ; MEMPROFNOCOLINFO: ![[MIB4]] = !{![[STACK4:[0-9]+]], !"cold"}
379 ; MEMPROFNOCOLINFO: ![[STACK4]] = !{i64 5281664982037379640, i64 -6871734214936418908}
380 ; MEMPROFNOCOLINFO: ![[MIB5]] = !{![[STACK5:[0-9]+]], !"cold"}
381 ; MEMPROFNOCOLINFO: ![[STACK5]] = !{i64 5281664982037379640, i64 -6201180255894224618}
382 ; MEMPROFNOCOLINFO: ![[C1]] = !{i64 5281664982037379640}
383 ; MEMPROFNOCOLINFO: ![[C2]] = !{i64 -6871734214936418908}
384 ; MEMPROFNOCOLINFO: ![[C3]] = !{i64 -5588766871448036195}
385 ; MEMPROFNOCOLINFO: ![[C4]] = !{i64 -8990226808646054327}
386 ; MEMPROFNOCOLINFO: ![[C5]] = !{i64 6362220161075421157}
387 ; MEMPROFNOCOLINFO: ![[C6]] = !{i64 -5772587307814069790}
388 ; MEMPROFNOCOLINFO: ![[C7]] = !{i64 -6896091699916449732}
389 ; MEMPROFNOCOLINFO: ![[C8]] = !{i64 -6201180255894224618}
390 ; MEMPROFNOCOLINFO: ![[C9]] = !{i64 -962804290746547393}
391 ; MEMPROFNOCOLINFO: ![[C10]] = !{i64 -4535090212904553409}
392 ; MEMPROFNOCOLINFO: ![[C11]] = !{i64 3577763375057267810}
394 ;; For the specific random seed, this is the expected order of hotness
395 ; MEMPROFRAND2: !"cold"
396 ; MEMPROFRAND2: !"cold"
397 ; MEMPROFRAND2: !"cold"
398 ; MEMPROFRAND2: !"hot"
399 ; MEMPROFRAND2: !"hot"
401 ; MEMPROFSTATS: 8 memprof - Number of alloc contexts in memory profile.
402 ; MEMPROFSTATS: 10 memprof - Number of callsites in memory profile.
403 ; MEMPROFSTATS: 6 memprof - Number of functions having valid memory profile.
404 ; MEMPROFSTATS: 8 memprof - Number of matched memory profile alloc contexts.
405 ; MEMPROFSTATS: 3 memprof - Number of matched memory profile allocs.
406 ; MEMPROFSTATS: 10 memprof - Number of matched memory profile callsites.
409 ; Function Attrs: argmemonly nofree nounwind willreturn writeonly
410 declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3
412 ; Function Attrs: nobuiltin nounwind
413 declare void @_ZdaPv(ptr noundef) #4
415 declare i32 @sleep(i32 noundef) #5
417 attributes #0 = { mustprogress noinline optnone uwtable "disable-tail-calls"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
418 attributes #1 = { nobuiltin allocsize(0) "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
419 attributes #2 = { mustprogress noinline norecurse optnone uwtable "disable-tail-calls"="true" "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
420 attributes #3 = { argmemonly nofree nounwind willreturn writeonly }
421 attributes #4 = { nobuiltin nounwind "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
422 attributes #5 = { "disable-tail-calls"="true" "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
423 attributes #6 = { builtin allocsize(0) }
424 attributes #7 = { builtin nounwind }
427 !llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
430 !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 15.0.0 (https://github.com/llvm/llvm-project.git 6cbe6284d1f0a088b5c6482ae27b738f03d82fe7)", isOptimized: false, runtimeVersion: 0, emissionKind: LineTablesOnly, splitDebugInlining: false, debugInfoForProfiling: true, nameTableKind: None)
431 !1 = !DIFile(filename: "memprof.cc", directory: "/usr/local/google/home/tejohnson/llvm/tmp", checksumkind: CSK_MD5, checksum: "e8c40ebe4b21776b4d60e9632cbc13c2")
432 !2 = !{i32 7, !"Dwarf Version", i32 5}
433 !3 = !{i32 2, !"Debug Info Version", i32 3}
434 !4 = !{i32 1, !"wchar_size", i32 4}
435 !5 = !{i32 7, !"PIC Level", i32 2}
436 !6 = !{i32 7, !"PIE Level", i32 2}
437 !7 = !{i32 7, !"uwtable", i32 2}
438 !8 = !{i32 7, !"frame-pointer", i32 2}
439 !9 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 6cbe6284d1f0a088b5c6482ae27b738f03d82fe7)"}
440 !10 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov", scope: !1, file: !1, line: 4, type: !11, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
441 !11 = !DISubroutineType(types: !12)
443 !13 = !DILocation(line: 5, column: 10, scope: !10)
444 !14 = !DILocation(line: 5, column: 3, scope: !10)
445 !15 = distinct !DISubprogram(name: "foo2", linkageName: "_Z4foo2v", scope: !1, file: !1, line: 7, type: !11, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
446 !16 = !DILocation(line: 8, column: 10, scope: !15)
447 !17 = !DILocation(line: 8, column: 3, scope: !15)
448 !18 = distinct !DISubprogram(name: "bar", linkageName: "_Z3barv", scope: !1, file: !1, line: 10, type: !11, scopeLine: 10, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
449 !19 = !DILocation(line: 11, column: 10, scope: !18)
450 !20 = !DILocation(line: 11, column: 3, scope: !18)
451 !21 = distinct !DISubprogram(name: "baz", linkageName: "_Z3bazv", scope: !1, file: !1, line: 13, type: !11, scopeLine: 13, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
452 !22 = !DILocation(line: 14, column: 10, scope: !21)
453 !23 = !DILocation(line: 14, column: 3, scope: !21)
454 !24 = distinct !DISubprogram(name: "recurse", linkageName: "_Z7recursej", scope: !1, file: !1, line: 16, type: !11, scopeLine: 16, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
455 !25 = !DILocation(line: 17, column: 8, scope: !24)
456 !26 = !DILocation(line: 17, column: 7, scope: !24)
457 !27 = !DILocation(line: 18, column: 12, scope: !24)
458 !28 = !DILocation(line: 18, column: 5, scope: !24)
459 !29 = !DILocation(line: 19, column: 18, scope: !24)
460 !30 = !DILocation(line: 19, column: 19, scope: !24)
461 !31 = !DILocation(line: 19, column: 10, scope: !24)
462 !32 = !DILocation(line: 19, column: 3, scope: !24)
463 !33 = !DILocation(line: 20, column: 1, scope: !24)
464 !34 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 21, type: !11, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)
465 !35 = !DILocation(line: 25, column: 13, scope: !34)
466 !36 = !DILocation(line: 25, column: 9, scope: !34)
467 !37 = !DILocation(line: 26, column: 13, scope: !34)
468 !38 = !DILocation(line: 26, column: 9, scope: !34)
469 !39 = !DILocation(line: 27, column: 13, scope: !34)
470 !40 = !DILocation(line: 27, column: 9, scope: !34)
471 !41 = !DILocation(line: 28, column: 13, scope: !34)
472 !42 = !DILocation(line: 28, column: 9, scope: !34)
473 !43 = !DILocation(line: 29, column: 13, scope: !34)
474 !44 = !DILocation(line: 29, column: 9, scope: !34)
475 !45 = !DILocation(line: 30, column: 13, scope: !34)
476 !46 = !DILocation(line: 30, column: 9, scope: !34)
477 !47 = !DILocation(line: 31, column: 10, scope: !34)
478 !48 = !DILocation(line: 31, column: 3, scope: !34)
479 !49 = !DILocation(line: 32, column: 10, scope: !34)
480 !50 = !DILocation(line: 32, column: 3, scope: !34)
481 !51 = !DILocation(line: 33, column: 10, scope: !34)
482 !52 = !DILocation(line: 33, column: 3, scope: !34)
483 !53 = !DILocation(line: 34, column: 10, scope: !34)
484 !54 = !DILocation(line: 34, column: 3, scope: !34)
485 !55 = !DILocation(line: 35, column: 10, scope: !34)
486 !56 = !DILocation(line: 35, column: 3, scope: !34)
487 !57 = !DILocation(line: 36, column: 10, scope: !34)
488 !58 = !DILocation(line: 36, column: 3, scope: !34)
489 !59 = !DILocation(line: 38, column: 12, scope: !34)
490 !60 = !DILocation(line: 38, column: 3, scope: !34)
491 !61 = !DILocation(line: 38, column: 3, scope: !62)
492 !62 = !DILexicalBlockFile(scope: !34, file: !1, discriminator: 2)
493 !63 = !DILocation(line: 39, column: 12, scope: !34)
494 !64 = !DILocation(line: 39, column: 3, scope: !34)
495 !65 = !DILocation(line: 39, column: 3, scope: !62)
496 !66 = !DILocation(line: 41, column: 3, scope: !34)
497 !67 = !DILocation(line: 42, column: 12, scope: !34)
498 !68 = !DILocation(line: 42, column: 3, scope: !34)
499 !69 = !DILocation(line: 42, column: 3, scope: !62)
500 !70 = !DILocation(line: 43, column: 12, scope: !34)
501 !71 = !DILocation(line: 43, column: 3, scope: !34)
502 !72 = !DILocation(line: 43, column: 3, scope: !62)
503 !73 = !DILocation(line: 44, column: 12, scope: !34)
504 !74 = !DILocation(line: 44, column: 3, scope: !34)
505 !75 = !DILocation(line: 44, column: 3, scope: !62)
506 !76 = !DILocation(line: 45, column: 12, scope: !34)
507 !77 = !DILocation(line: 45, column: 3, scope: !34)
508 !78 = !DILocation(line: 45, column: 3, scope: !62)
509 !79 = !DILocation(line: 51, column: 17, scope: !34)
510 !80 = !DILocation(line: 51, column: 8, scope: !34)
511 !81 = !DILocation(line: 51, column: 24, scope: !62)
512 !82 = !DILocation(line: 51, column: 26, scope: !62)
513 !83 = !DILocation(line: 51, column: 3, scope: !62)
514 !84 = !DILocation(line: 52, column: 23, scope: !34)
515 !85 = !DILocation(line: 52, column: 25, scope: !34)
516 !86 = !DILocation(line: 52, column: 15, scope: !34)
517 !87 = !DILocation(line: 52, column: 11, scope: !34)
518 !88 = !DILocation(line: 53, column: 12, scope: !34)
519 !89 = !DILocation(line: 53, column: 5, scope: !34)
520 !90 = !DILocation(line: 54, column: 10, scope: !34)
521 !91 = !DILocation(line: 54, column: 9, scope: !34)
522 !92 = !DILocation(line: 55, column: 7, scope: !34)
523 !93 = !DILocation(line: 56, column: 14, scope: !34)
524 !94 = !DILocation(line: 56, column: 5, scope: !34)
525 !95 = !DILocation(line: 56, column: 5, scope: !62)
526 !96 = !DILocation(line: 57, column: 3, scope: !34)
527 !97 = !DILocation(line: 51, column: 32, scope: !98)
528 !98 = !DILexicalBlockFile(scope: !34, file: !1, discriminator: 4)
529 !99 = !DILocation(line: 51, column: 3, scope: !98)
530 !100 = distinct !{!100, !101, !96, !102}
531 !101 = !DILocation(line: 51, column: 3, scope: !34)
532 !102 = !{!"llvm.loop.mustprogress"}
533 !103 = !DILocation(line: 58, column: 3, scope: !34)