brintos

brintos / llvm-project-archived public Read only

0
0
Text · 34.7 KiB · f6a89a8 Raw
591 lines · plain
1;; Tests memprof profile matching (with and without instrumentation profiles).2 3;; Several requirements due to using raw profile inputs:4;; PGO profile uses zlib compression5; REQUIRES: zlib6;; Avoid failures on big-endian systems that can't read the profile properly7; REQUIRES: x86_64-linux8;; -stats requires asserts9; REQUIRES: asserts10 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-llvm16 17;; Generate indexed profiles of all combinations:18; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata19; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.pgomemprofdata20; RUN: llvm-profdata merge %S/Inputs/memprof_pgo.proftext -o %t.pgoprofdata21; RUN: llvm-profdata merge %S/Inputs/memprof.nocolinfo.memprofraw --profiled-binary %S/Inputs/memprof.nocolinfo.exe -o %t.nocolinfo.memprofdata22 23;; Check that the summary can be shown (and is identical) for both the raw and indexed profiles.24; RUN: llvm-profdata show --memory %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe | FileCheck %s --check-prefixes=SUMMARY25; RUN: llvm-profdata show --memory %t.memprofdata | FileCheck %s --check-prefixes=SUMMARY26; SUMMARY: # MemProfSummary:27; SUMMARY: #   Total contexts: 828; SUMMARY: #   Total cold contexts: 529; SUMMARY: #   Total hot contexts: 030; SUMMARY: #   Maximum cold context total size: 1031; SUMMARY: #   Maximum warm context total size: 1032; SUMMARY: #   Maximum hot context total size: 033 34;; In all below cases we should not get any messages about missing profile data35;; for any functions. Either we are not performing any matching for a particular36;; profile type or we are performing the matching and it should be successful.37; ALL-NOT: memprof record not found for function hash38; ALL-NOT: no profile data available for function39 40;; Using a memprof-only profile for memprof-use should only give memprof metadata41; 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,AMBIG42; There should not be any PGO metadata43; MEMPROFONLY-NOT: !prof44 45;; Try again but using a profile with missing columns. The memprof matcher46;; should recognize that there are no non-zero columns in the profile and47;; not attempt to include column numbers in the matching (which means that the48;; stack ids will be different).49; RUN: opt < %s -passes='memprof-use<profile-filename=%t.nocolinfo.memprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFNOCOLINFO,ALL,MEMPROFONLY50 51;; Test the same thing but by passing the memory profile through to a default52;; pipeline via -memory-profile-file=, which should cause the necessary field53;; of the PGOOptions structure to be populated with the profile filename.54; 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,AMBIG55 56;; Using a pgo+memprof profile for memprof-use should only give memprof metadata57; RUN: opt < %s -passes='memprof-use<profile-filename=%t.pgomemprofdata>' -pgo-warn-missing-function -S 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,MEMPROFONLY,AMBIG58 59;; Using a pgo-only profile for memprof-use should give an error60; RUN: not opt < %s -passes='memprof-use<profile-filename=%t.pgoprofdata>' -S 2>&1 | FileCheck %s --check-prefixes=MEMPROFWITHPGOONLY61; MEMPROFWITHPGOONLY: Not a memory profile62 63;; Using a memprof-only profile for pgo-instr-use should give an error64; RUN: not opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -S 2>&1 | FileCheck %s --check-prefixes=PGOWITHMEMPROFONLY65; PGOWITHMEMPROFONLY: Not an IR level instrumentation profile66 67;; Using a pgo+memprof profile for pgo-instr-use should only give pgo metadata68; 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,PGOONLY69; There should not be any memprof related metadata70; PGOONLY-NOT: !memprof71; PGOONLY-NOT: !callsite72 73;; Using a pgo+memprof profile for both memprof-use and pgo-instr-use should74;; give both memprof and pgo metadata.75; 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,AMBIG76 77;; Check that the total sizes are reported if requested. A message should be78;; emitted for the pruned context. Also check that remarks are emitted for the79;; allocations hinted without context sensitivity.80; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -pass-remarks=memory-profile-info 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZENOKEEPALL,REMARKSINGLE81 82;; Check that the total sizes are reported if requested, and prevent pruning83;; via -memprof-keep-all-not-cold-contexts.84; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZES,TOTALSIZESKEEPALL85 86;; Check that we hint additional allocations with a threshold < 100%87; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-report-hinted-sizes -memprof-matching-cold-threshold=60 2>&1 | FileCheck %s --check-prefixes=TOTALSIZESSINGLE,TOTALSIZESTHRESH6088 89;; Make sure that the -memprof-cloning-cold-threshold flag is enough to cause90;; the size metadata to be generated for the LTO link.91; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-cloning-cold-threshold=80 -memprof-keep-all-not-cold-contexts 2>&1 | FileCheck %s --check-prefixes=TOTALSIZES,TOTALSIZESKEEPALL92 93;; Make sure we emit a random hotness seed if requested.94; 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=RAND95; RAND: random hotness seed =96;; Can't check the exact values, but make sure applying the random profile97;; succeeds with the same stats98; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdatarand>' -pgo-warn-missing-function -S -stats 2>&1 | FileCheck %s --check-prefixes=ALL,MEMPROFONLY,MEMPROFSTATS99 100;; Make sure we use a specific random hotness seed if requested.101; 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=RAND2102; RAND2: random hotness seed = 1730170724103; 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,MEMPROFSTATS104 105;; With the hot access density threshold set to 0, and hot hints enabled,106;; the unconditionally notcold call to new should instead get a hot attribute.107; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-print-match-info -stats -memprof-min-ave-lifetime-access-density-hot-threshold=0 -memprof-use-hot-hints 2>&1 | FileCheck %s --check-prefixes=MEMPROFHOT,ALL108 109;; However, with the same threshold, but hot hints not enabled, it should be110;; notcold again.111; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-min-ave-lifetime-access-density-hot-threshold=0 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,AMBIG112 113;; Test that we don't get an ambiguous memprof attribute when114;; -memprof-ambiguous-attributes is disabled.115; RUN: opt < %s -passes='memprof-use<profile-filename=%t.memprofdata>' -pgo-warn-missing-function -S -memprof-ambiguous-attributes=false 2>&1 | FileCheck %s --check-prefixes=MEMPROF,ALL,NOAMBIG116 117; MEMPROFMATCHINFO: MemProf notcold context with id 1093248920606587996 has total profiled size 10 is matched with 1 frames118; MEMPROFMATCHINFO: MemProf notcold context with id 5725971306423925017 has total profiled size 10 is matched with 1 frames119; MEMPROFMATCHINFO: MemProf notcold context with id 6792096022461663180 has total profiled size 10 is matched with 1 frames120; MEMPROFMATCHINFO: MemProf cold context with id 8525406123785421946 has total profiled size 10 is matched with 1 frames121; MEMPROFMATCHINFO: MemProf cold context with id 11714230664165068698 has total profiled size 10 is matched with 1 frames122; MEMPROFMATCHINFO: MemProf cold context with id 15737101490731057601 has total profiled size 10 is matched with 1 frames123; MEMPROFMATCHINFO: MemProf cold context with id 16342802530253093571 has total profiled size 10 is matched with 1 frames124; MEMPROFMATCHINFO: MemProf cold context with id 18254812774972004394 has total profiled size 10 is matched with 1 frames125; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 748269490701775343126; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 1544787832369987002127; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 2061451396820446691128; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 2104812325165620841129; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 6281715513834610934130; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 8467819354083268568131; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 8690657650969109624132; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 9086428284934609951133; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 12481870273128938184134; MEMPROFMATCHINFO: MemProf callsite match for inline call stack 12699492813229484831135 136; ModuleID = 'memprof.cc'137source_filename = "memprof.cc"138target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"139target triple = "x86_64-unknown-linux-gnu"140 141; Function Attrs: mustprogress noinline optnone uwtable142; ALL-LABEL: define dso_local noundef{{.*}}ptr @_Z3foov()143; There should be some PGO metadata144; PGO: !prof145define dso_local noundef ptr @_Z3foov() #0 !dbg !10 {146entry:147  ; MEMPROF: call {{.*}} @_Znam{{.*}} #[[A0:[0-9]+]]{{.*}} !memprof ![[M1:[0-9]+]], !callsite ![[C1:[0-9]+]]148  ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} !memprof ![[M1:[0-9]+]], !callsite ![[C1:[0-9]+]]149  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !13150  ret ptr %call, !dbg !14151}152 153; Function Attrs: nobuiltin allocsize(0)154declare noundef nonnull ptr @_Znam(i64 noundef) #1155 156; Function Attrs: mustprogress noinline optnone uwtable157; ALL-LABEL: define dso_local noundef{{.*}}ptr @_Z4foo2v()158define dso_local noundef ptr @_Z4foo2v() #0 !dbg !15 {159entry:160  ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C2:[0-9]+]]161  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C2:[0-9]+]]162  %call = call noundef ptr @_Z3foov(), !dbg !16163  ret ptr %call, !dbg !17164}165 166; Function Attrs: mustprogress noinline optnone uwtable167define dso_local noundef ptr @_Z3barv() #0 !dbg !18 {168entry:169  ; MEMPROF: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C3:[0-9]+]]170  ; MEMPROFNOCOLINFO: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C3:[0-9]+]]171  %call = call noundef ptr @_Z4foo2v(), !dbg !19172  ret ptr %call, !dbg !20173}174 175; Function Attrs: mustprogress noinline optnone uwtable176define dso_local noundef ptr @_Z3bazv() #0 !dbg !21 {177entry:178  ; MEMPROF: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C4:[0-9]+]]179  ; MEMPROFNOCOLINFO: call {{.*}} @_Z4foo2v{{.*}} !callsite ![[C4:[0-9]+]]180  %call = call noundef ptr @_Z4foo2v(), !dbg !22181  ret ptr %call, !dbg !23182}183 184; Function Attrs: mustprogress noinline optnone uwtable185define dso_local noundef ptr @_Z7recursej(i32 noundef %n) #0 !dbg !24 {186entry:187  %retval = alloca ptr, align 8188  %n.addr = alloca i32, align 4189  store i32 %n, ptr %n.addr, align 4190  %0 = load i32, ptr %n.addr, align 4, !dbg !25191  %tobool = icmp ne i32 %0, 0, !dbg !25192  br i1 %tobool, label %if.end, label %if.then, !dbg !26193 194if.then:                                          ; preds = %entry195  ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C5:[0-9]+]]196  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C5:[0-9]+]]197  %call = call noundef ptr @_Z3foov(), !dbg !27198  store ptr %call, ptr %retval, align 8, !dbg !28199  br label %return, !dbg !28200 201if.end:                                           ; preds = %entry202  %1 = load i32, ptr %n.addr, align 4, !dbg !29203  %sub = sub i32 %1, 1, !dbg !30204  ; MEMPROF: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C6:[0-9]+]]205  ; MEMPROFNOCOLINFO: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C6:[0-9]+]]206  %call1 = call noundef ptr @_Z7recursej(i32 noundef %sub), !dbg !31207  store ptr %call1, ptr %retval, align 8, !dbg !32208  br label %return, !dbg !32209 210return:                                           ; preds = %if.end, %if.then211  %2 = load ptr, ptr %retval, align 8, !dbg !33212  ret ptr %2, !dbg !33213}214 215; Function Attrs: mustprogress noinline norecurse optnone uwtable216define dso_local noundef i32 @main(i32 noundef %argc, ptr noundef %argv) #2 !dbg !34 {217entry:218  %retval = alloca i32, align 4219  %argc.addr = alloca i32, align 4220  %argv.addr = alloca ptr, align 8221  %a = alloca ptr, align 8222  %b = alloca ptr, align 8223  %c = alloca ptr, align 8224  %d = alloca ptr, align 8225  %e = alloca ptr, align 8226  %f = alloca ptr, align 8227  %i = alloca i32, align 4228  %g = alloca ptr, align 8229  store i32 0, ptr %retval, align 4230  store i32 %argc, ptr %argc.addr, align 4231  store ptr %argv, ptr %argv.addr, align 8232  ; MEMPROF: call {{.*}} @_Znam{{.*}} #[[A1:[0-9]+]]233  ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} #[[A1:[0-9]+]]234  ; MEMPROFHOT: call {{.*}} @_Znam{{.*}} #[[A1:[0-9]+]]235  %call = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !35236  store ptr %call, ptr %a, align 8, !dbg !36237  ; MEMPROF: call {{.*}} @_Znam{{.*}} #[[A2:[0-9]+]]238  ; MEMPROFNOCOLINFO: call {{.*}} @_Znam{{.*}} #[[A2:[0-9]+]]239  %call1 = call noalias noundef nonnull ptr @_Znam(i64 noundef 10) #6, !dbg !37240  store ptr %call1, ptr %b, align 8, !dbg !38241  ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C7:[0-9]+]]242  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C7:[0-9]+]]243  %call2 = call noundef ptr @_Z3foov(), !dbg !39244  store ptr %call2, ptr %c, align 8, !dbg !40245  ; MEMPROF: call {{.*}} @_Z3foov{{.*}} !callsite ![[C8:[0-9]+]]246  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3foov{{.*}} !callsite ![[C8:[0-9]+]]247  %call3 = call noundef ptr @_Z3foov(), !dbg !41248  store ptr %call3, ptr %d, align 8, !dbg !42249  ; MEMPROF: call {{.*}} @_Z3barv{{.*}} !callsite ![[C9:[0-9]+]]250  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3barv{{.*}} !callsite ![[C9:[0-9]+]]251  %call4 = call noundef ptr @_Z3barv(), !dbg !43252  store ptr %call4, ptr %e, align 8, !dbg !44253  ; MEMPROF: call {{.*}} @_Z3bazv{{.*}} !callsite ![[C10:[0-9]+]]254  ; MEMPROFNOCOLINFO: call {{.*}} @_Z3bazv{{.*}} !callsite ![[C10:[0-9]+]]255  %call5 = call noundef ptr @_Z3bazv(), !dbg !45256  store ptr %call5, ptr %f, align 8, !dbg !46257  %0 = load ptr, ptr %a, align 8, !dbg !47258  call void @llvm.memset.p0.i64(ptr align 1 %0, i8 0, i64 10, i1 false), !dbg !48259  %1 = load ptr, ptr %b, align 8, !dbg !49260  call void @llvm.memset.p0.i64(ptr align 1 %1, i8 0, i64 10, i1 false), !dbg !50261  %2 = load ptr, ptr %c, align 8, !dbg !51262  call void @llvm.memset.p0.i64(ptr align 1 %2, i8 0, i64 10, i1 false), !dbg !52263  %3 = load ptr, ptr %d, align 8, !dbg !53264  call void @llvm.memset.p0.i64(ptr align 1 %3, i8 0, i64 10, i1 false), !dbg !54265  %4 = load ptr, ptr %e, align 8, !dbg !55266  call void @llvm.memset.p0.i64(ptr align 1 %4, i8 0, i64 10, i1 false), !dbg !56267  %5 = load ptr, ptr %f, align 8, !dbg !57268  call void @llvm.memset.p0.i64(ptr align 1 %5, i8 0, i64 10, i1 false), !dbg !58269  %6 = load ptr, ptr %a, align 8, !dbg !59270  %isnull = icmp eq ptr %6, null, !dbg !60271  br i1 %isnull, label %delete.end, label %delete.notnull, !dbg !60272 273delete.notnull:                                   ; preds = %entry274  call void @_ZdaPv(ptr noundef %6) #7, !dbg !61275  br label %delete.end, !dbg !61276 277delete.end:                                       ; preds = %delete.notnull, %entry278  %7 = load ptr, ptr %c, align 8, !dbg !63279  %isnull6 = icmp eq ptr %7, null, !dbg !64280  br i1 %isnull6, label %delete.end8, label %delete.notnull7, !dbg !64281 282delete.notnull7:                                  ; preds = %delete.end283  call void @_ZdaPv(ptr noundef %7) #7, !dbg !65284  br label %delete.end8, !dbg !65285 286delete.end8:                                      ; preds = %delete.notnull7, %delete.end287  %call9 = call i32 @sleep(i32 noundef 200), !dbg !66288  %8 = load ptr, ptr %b, align 8, !dbg !67289  %isnull10 = icmp eq ptr %8, null, !dbg !68290  br i1 %isnull10, label %delete.end12, label %delete.notnull11, !dbg !68291 292delete.notnull11:                                 ; preds = %delete.end8293  call void @_ZdaPv(ptr noundef %8) #7, !dbg !69294  br label %delete.end12, !dbg !69295 296delete.end12:                                     ; preds = %delete.notnull11, %delete.end8297  %9 = load ptr, ptr %d, align 8, !dbg !70298  %isnull13 = icmp eq ptr %9, null, !dbg !71299  br i1 %isnull13, label %delete.end15, label %delete.notnull14, !dbg !71300 301delete.notnull14:                                 ; preds = %delete.end12302  call void @_ZdaPv(ptr noundef %9) #7, !dbg !72303  br label %delete.end15, !dbg !72304 305delete.end15:                                     ; preds = %delete.notnull14, %delete.end12306  %10 = load ptr, ptr %e, align 8, !dbg !73307  %isnull16 = icmp eq ptr %10, null, !dbg !74308  br i1 %isnull16, label %delete.end18, label %delete.notnull17, !dbg !74309 310delete.notnull17:                                 ; preds = %delete.end15311  call void @_ZdaPv(ptr noundef %10) #7, !dbg !75312  br label %delete.end18, !dbg !75313 314delete.end18:                                     ; preds = %delete.notnull17, %delete.end15315  %11 = load ptr, ptr %f, align 8, !dbg !76316  %isnull19 = icmp eq ptr %11, null, !dbg !77317  br i1 %isnull19, label %delete.end21, label %delete.notnull20, !dbg !77318 319delete.notnull20:                                 ; preds = %delete.end18320  call void @_ZdaPv(ptr noundef %11) #7, !dbg !78321  br label %delete.end21, !dbg !78322 323delete.end21:                                     ; preds = %delete.notnull20, %delete.end18324  store i32 0, ptr %i, align 4, !dbg !79325  br label %for.cond, !dbg !80326 327for.cond:                                         ; preds = %for.inc, %delete.end21328  %12 = load i32, ptr %i, align 4, !dbg !81329  %cmp = icmp ult i32 %12, 2, !dbg !82330  br i1 %cmp, label %for.body, label %for.end, !dbg !83331 332for.body:                                         ; preds = %for.cond333  %13 = load i32, ptr %i, align 4, !dbg !84334  %add = add i32 %13, 3, !dbg !85335  ; MEMPROF: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C11:[0-9]+]]336  ; MEMPROFNOCOLINFO: call {{.*}} @_Z7recursej{{.*}} !callsite ![[C11:[0-9]+]]337  %call22 = call noundef ptr @_Z7recursej(i32 noundef %add), !dbg !86338  store ptr %call22, ptr %g, align 8, !dbg !87339  %14 = load ptr, ptr %g, align 8, !dbg !88340  call void @llvm.memset.p0.i64(ptr align 1 %14, i8 0, i64 10, i1 false), !dbg !89341  %15 = load i32, ptr %i, align 4, !dbg !90342  %tobool = icmp ne i32 %15, 0, !dbg !90343  br i1 %tobool, label %if.end, label %if.then, !dbg !91344 345if.then:                                          ; preds = %for.body346  %call23 = call i32 @sleep(i32 noundef 200), !dbg !92347  br label %if.end, !dbg !92348 349if.end:                                           ; preds = %if.then, %for.body350  %16 = load ptr, ptr %g, align 8, !dbg !93351  %isnull24 = icmp eq ptr %16, null, !dbg !94352  br i1 %isnull24, label %delete.end26, label %delete.notnull25, !dbg !94353 354delete.notnull25:                                 ; preds = %if.end355  call void @_ZdaPv(ptr noundef %16) #7, !dbg !95356  br label %delete.end26, !dbg !95357 358delete.end26:                                     ; preds = %delete.notnull25, %if.end359  br label %for.inc, !dbg !96360 361for.inc:                                          ; preds = %delete.end26362  %17 = load i32, ptr %i, align 4, !dbg !97363  %inc = add i32 %17, 1, !dbg !97364  store i32 %inc, ptr %i, align 4, !dbg !97365  br label %for.cond, !dbg !99, !llvm.loop !100366 367for.end:                                          ; preds = %for.cond368  ret i32 0, !dbg !103369}370 371;; We optionally apply an ambiguous memprof attribute to ambiguous allocations372; AMBIG: #[[A0]] = { builtin allocsize(0) "memprof"="ambiguous" }373; NOAMBIG: #[[A0]] = { builtin allocsize(0) }374; MEMPROF: #[[A1]] = { builtin allocsize(0) "memprof"="notcold" }375; MEMPROF: #[[A2]] = { builtin allocsize(0) "memprof"="cold" }376; MEMPROF: ![[M1]] = !{![[MIB1:[0-9]+]], ![[MIB2:[0-9]+]], ![[MIB3:[0-9]+]], ![[MIB4:[0-9]+]]}377; MEMPROF: ![[MIB1]] = !{![[STACK1:[0-9]+]], !"cold"}378; MEMPROF: ![[STACK1]] = !{i64 2732490490862098848, i64 748269490701775343}379; MEMPROF: ![[MIB2]] = !{![[STACK2:[0-9]+]], !"cold"}380; MEMPROF: ![[STACK2]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 1544787832369987002}381; MEMPROF: ![[MIB3]] = !{![[STACK3:[0-9]+]], !"notcold"}382; MEMPROF: ![[STACK3]] = !{i64 2732490490862098848, i64 2104812325165620841, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934, i64 6281715513834610934}383; MEMPROF: ![[MIB4]] = !{![[STACK4:[0-9]+]], !"cold"}384; MEMPROF: ![[STACK4]] = !{i64 2732490490862098848, i64 8467819354083268568}385; MEMPROF: ![[C1]] = !{i64 2732490490862098848}386; MEMPROF: ![[C2]] = !{i64 8467819354083268568}387; MEMPROF: ![[C3]] = !{i64 9086428284934609951}388; MEMPROF: ![[C4]] = !{i64 -5964873800580613432}389; MEMPROF: ![[C5]] = !{i64 2104812325165620841}390; MEMPROF: ![[C6]] = !{i64 6281715513834610934}391; MEMPROF: ![[C7]] = !{i64 8690657650969109624}392; MEMPROF: ![[C8]] = !{i64 748269490701775343}393; MEMPROF: ![[C9]] = !{i64 -5747251260480066785}394; MEMPROF: ![[C10]] = !{i64 2061451396820446691}395; MEMPROF: ![[C11]] = !{i64 1544787832369987002}396 397; TOTALSIZENOKEEPALL: Total size for pruned non-cold full allocation context hash 1093248920606587996: 10398 399;; For non-context sensitive allocations that get attributes we emit a message400;; with the full allocation context hash, type, and size in bytes.401; TOTALSIZESTHRESH60: Total size for full allocation context hash 8525406123785421946 and dominant alloc type cold: 10402; TOTALSIZESTHRESH60: Total size for full allocation context hash 11714230664165068698 and dominant alloc type cold: 10403; TOTALSIZESTHRESH60: Total size for full allocation context hash 5725971306423925017 and dominant alloc type cold: 10404; TOTALSIZESTHRESH60: Total size for full allocation context hash 16342802530253093571 and dominant alloc type cold: 10405; TOTALSIZESTHRESH60: Total size for full allocation context hash 18254812774972004394 and dominant alloc type cold: 10406; TOTALSIZESTHRESH60: Total size for full allocation context hash 1093248920606587996 and dominant alloc type cold: 10407; TOTALSIZESSINGLE: Total size for full allocation context hash 6792096022461663180 and single alloc type notcold: 10408; REMARKSINGLE: remark: memprof.cc:25:13: call in function main marked with memprof allocation attribute notcold409; TOTALSIZESSINGLE: Total size for full allocation context hash 15737101490731057601 and single alloc type cold: 10410; REMARKSINGLE: remark: memprof.cc:26:13: call in function main marked with memprof allocation attribute cold411;; For context sensitive allocations the full context hash and size in bytes412;; are in separate metadata nodes included on the MIB metadata.413; TOTALSIZES: !"cold", ![[CONTEXT1:[0-9]+]]}414; TOTALSIZES: ![[CONTEXT1]] = !{i64 8525406123785421946, i64 10}415; TOTALSIZES: !"cold", ![[CONTEXT2:[0-9]+]]}416; TOTALSIZES: ![[CONTEXT2]] = !{i64 -6732513409544482918, i64 10}417; TOTALSIZES: !"notcold", ![[CONTEXT3:[0-9]+]]}418; TOTALSIZES: ![[CONTEXT3]] = !{i64 5725971306423925017, i64 10}419;; There can be more than one context id / size pair due to context trimming420;; when we match.421; TOTALSIZES: !"cold", ![[CONTEXT4:[0-9]+]], ![[CONTEXT5:[0-9]+]]}422; TOTALSIZES: ![[CONTEXT4]] = !{i64 -2103941543456458045, i64 10}423; TOTALSIZES: ![[CONTEXT5]] = !{i64 -191931298737547222, i64 10}424; TOTALSIZESKEEPALL: !"notcold", ![[CONTEXT6:[0-9]+]]}425; TOTALSIZESKEEPALL: ![[CONTEXT6]] = !{i64 1093248920606587996, i64 10}426 427; MEMPROFNOCOLINFO: #[[A1]] = { builtin allocsize(0) "memprof"="notcold" }428; MEMPROFNOCOLINFO: #[[A2]] = { builtin allocsize(0) "memprof"="cold" }429; MEMPROFNOCOLINFO: ![[M1]] = !{![[MIB1:[0-9]+]], ![[MIB2:[0-9]+]], ![[MIB3:[0-9]+]], ![[MIB4:[0-9]+]]}430; MEMPROFNOCOLINFO: ![[MIB1]] = !{![[STACK1:[0-9]+]], !"cold"}431; MEMPROFNOCOLINFO: ![[STACK1]] = !{i64 5281664982037379640, i64 6362220161075421157, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790, i64 3577763375057267810}432; MEMPROFNOCOLINFO: ![[MIB2]] = !{![[STACK2:[0-9]+]], !"notcold"}433; MEMPROFNOCOLINFO: ![[STACK2]] = !{i64 5281664982037379640, i64 6362220161075421157, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790, i64 -5772587307814069790}434; MEMPROFNOCOLINFO: ![[MIB3]] = !{![[STACK3:[0-9]+]], !"cold"}435; MEMPROFNOCOLINFO: ![[STACK3]] = !{i64 5281664982037379640, i64 -6871734214936418908}436; MEMPROFNOCOLINFO: ![[MIB4]] = !{![[STACK4:[0-9]+]], !"cold"}437; MEMPROFNOCOLINFO: ![[STACK4]] = !{i64 5281664982037379640, i64 -6201180255894224618}438; MEMPROFNOCOLINFO: ![[C1]] = !{i64 5281664982037379640}439; MEMPROFNOCOLINFO: ![[C2]] = !{i64 -6871734214936418908}440; MEMPROFNOCOLINFO: ![[C3]] = !{i64 -5588766871448036195}441; MEMPROFNOCOLINFO: ![[C4]] = !{i64 -8990226808646054327}442; MEMPROFNOCOLINFO: ![[C5]] = !{i64 6362220161075421157}443; MEMPROFNOCOLINFO: ![[C6]] = !{i64 -5772587307814069790}444; MEMPROFNOCOLINFO: ![[C7]] = !{i64 -6896091699916449732}445; MEMPROFNOCOLINFO: ![[C8]] = !{i64 -6201180255894224618}446; MEMPROFNOCOLINFO: ![[C9]] = !{i64 -962804290746547393}447; MEMPROFNOCOLINFO: ![[C10]] = !{i64 -4535090212904553409}448; MEMPROFNOCOLINFO: ![[C11]] = !{i64 3577763375057267810}449 450; MEMPROFHOT: #[[A1]] = { builtin allocsize(0) "memprof"="hot" }451 452;; For the specific random seed, this is the expected order of hotness453; MEMPROFRAND2: !"cold"454; MEMPROFRAND2: !"cold"455; MEMPROFRAND2: !"cold"456; MEMPROFRAND2: !"notcold"457 458; MEMPROFSTATS:  8 memprof - Number of alloc contexts in memory profile.459; MEMPROFSTATS: 10 memprof - Number of callsites in memory profile.460; MEMPROFSTATS:  6 memprof - Number of functions having valid memory profile.461; MEMPROFSTATS:  8 memprof - Number of matched memory profile alloc contexts.462; MEMPROFSTATS:  3 memprof - Number of matched memory profile allocs.463; MEMPROFSTATS: 10 memprof - Number of matched memory profile callsites.464 465 466; Function Attrs: argmemonly nofree nounwind willreturn writeonly467declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #3468 469; Function Attrs: nobuiltin nounwind470declare void @_ZdaPv(ptr noundef) #4471 472declare i32 @sleep(i32 noundef) #5473 474attributes #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" }475attributes #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" }476attributes #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" }477attributes #3 = { argmemonly nofree nounwind willreturn writeonly }478attributes #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" }479attributes #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" }480attributes #6 = { builtin allocsize(0) }481attributes #7 = { builtin nounwind }482 483!llvm.dbg.cu = !{!0}484!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}485!llvm.ident = !{!9}486 487!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)488!1 = !DIFile(filename: "memprof.cc", directory: "/usr/local/google/home/tejohnson/llvm/tmp", checksumkind: CSK_MD5, checksum: "e8c40ebe4b21776b4d60e9632cbc13c2")489!2 = !{i32 7, !"Dwarf Version", i32 5}490!3 = !{i32 2, !"Debug Info Version", i32 3}491!4 = !{i32 1, !"wchar_size", i32 4}492!5 = !{i32 7, !"PIC Level", i32 2}493!6 = !{i32 7, !"PIE Level", i32 2}494!7 = !{i32 7, !"uwtable", i32 2}495!8 = !{i32 7, !"frame-pointer", i32 2}496!9 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 6cbe6284d1f0a088b5c6482ae27b738f03d82fe7)"}497!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)498!11 = !DISubroutineType(types: !12)499!12 = !{}500!13 = !DILocation(line: 5, column: 10, scope: !10)501!14 = !DILocation(line: 5, column: 3, scope: !10)502!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)503!16 = !DILocation(line: 8, column: 10, scope: !15)504!17 = !DILocation(line: 8, column: 3, scope: !15)505!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)506!19 = !DILocation(line: 11, column: 10, scope: !18)507!20 = !DILocation(line: 11, column: 3, scope: !18)508!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)509!22 = !DILocation(line: 14, column: 10, scope: !21)510!23 = !DILocation(line: 14, column: 3, scope: !21)511!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)512!25 = !DILocation(line: 17, column: 8, scope: !24)513!26 = !DILocation(line: 17, column: 7, scope: !24)514!27 = !DILocation(line: 18, column: 12, scope: !24)515!28 = !DILocation(line: 18, column: 5, scope: !24)516!29 = !DILocation(line: 19, column: 18, scope: !24)517!30 = !DILocation(line: 19, column: 19, scope: !24)518!31 = !DILocation(line: 19, column: 10, scope: !24)519!32 = !DILocation(line: 19, column: 3, scope: !24)520!33 = !DILocation(line: 20, column: 1, scope: !24)521!34 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 21, type: !11, scopeLine: 21, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !12)522!35 = !DILocation(line: 25, column: 13, scope: !34)523!36 = !DILocation(line: 25, column: 9, scope: !34)524!37 = !DILocation(line: 26, column: 13, scope: !34)525!38 = !DILocation(line: 26, column: 9, scope: !34)526!39 = !DILocation(line: 27, column: 13, scope: !34)527!40 = !DILocation(line: 27, column: 9, scope: !34)528!41 = !DILocation(line: 28, column: 13, scope: !34)529!42 = !DILocation(line: 28, column: 9, scope: !34)530!43 = !DILocation(line: 29, column: 13, scope: !34)531!44 = !DILocation(line: 29, column: 9, scope: !34)532!45 = !DILocation(line: 30, column: 13, scope: !34)533!46 = !DILocation(line: 30, column: 9, scope: !34)534!47 = !DILocation(line: 31, column: 10, scope: !34)535!48 = !DILocation(line: 31, column: 3, scope: !34)536!49 = !DILocation(line: 32, column: 10, scope: !34)537!50 = !DILocation(line: 32, column: 3, scope: !34)538!51 = !DILocation(line: 33, column: 10, scope: !34)539!52 = !DILocation(line: 33, column: 3, scope: !34)540!53 = !DILocation(line: 34, column: 10, scope: !34)541!54 = !DILocation(line: 34, column: 3, scope: !34)542!55 = !DILocation(line: 35, column: 10, scope: !34)543!56 = !DILocation(line: 35, column: 3, scope: !34)544!57 = !DILocation(line: 36, column: 10, scope: !34)545!58 = !DILocation(line: 36, column: 3, scope: !34)546!59 = !DILocation(line: 38, column: 12, scope: !34)547!60 = !DILocation(line: 38, column: 3, scope: !34)548!61 = !DILocation(line: 38, column: 3, scope: !62)549!62 = !DILexicalBlockFile(scope: !34, file: !1, discriminator: 2)550!63 = !DILocation(line: 39, column: 12, scope: !34)551!64 = !DILocation(line: 39, column: 3, scope: !34)552!65 = !DILocation(line: 39, column: 3, scope: !62)553!66 = !DILocation(line: 41, column: 3, scope: !34)554!67 = !DILocation(line: 42, column: 12, scope: !34)555!68 = !DILocation(line: 42, column: 3, scope: !34)556!69 = !DILocation(line: 42, column: 3, scope: !62)557!70 = !DILocation(line: 43, column: 12, scope: !34)558!71 = !DILocation(line: 43, column: 3, scope: !34)559!72 = !DILocation(line: 43, column: 3, scope: !62)560!73 = !DILocation(line: 44, column: 12, scope: !34)561!74 = !DILocation(line: 44, column: 3, scope: !34)562!75 = !DILocation(line: 44, column: 3, scope: !62)563!76 = !DILocation(line: 45, column: 12, scope: !34)564!77 = !DILocation(line: 45, column: 3, scope: !34)565!78 = !DILocation(line: 45, column: 3, scope: !62)566!79 = !DILocation(line: 51, column: 17, scope: !34)567!80 = !DILocation(line: 51, column: 8, scope: !34)568!81 = !DILocation(line: 51, column: 24, scope: !62)569!82 = !DILocation(line: 51, column: 26, scope: !62)570!83 = !DILocation(line: 51, column: 3, scope: !62)571!84 = !DILocation(line: 52, column: 23, scope: !34)572!85 = !DILocation(line: 52, column: 25, scope: !34)573!86 = !DILocation(line: 52, column: 15, scope: !34)574!87 = !DILocation(line: 52, column: 11, scope: !34)575!88 = !DILocation(line: 53, column: 12, scope: !34)576!89 = !DILocation(line: 53, column: 5, scope: !34)577!90 = !DILocation(line: 54, column: 10, scope: !34)578!91 = !DILocation(line: 54, column: 9, scope: !34)579!92 = !DILocation(line: 55, column: 7, scope: !34)580!93 = !DILocation(line: 56, column: 14, scope: !34)581!94 = !DILocation(line: 56, column: 5, scope: !34)582!95 = !DILocation(line: 56, column: 5, scope: !62)583!96 = !DILocation(line: 57, column: 3, scope: !34)584!97 = !DILocation(line: 51, column: 32, scope: !98)585!98 = !DILexicalBlockFile(scope: !34, file: !1, discriminator: 4)586!99 = !DILocation(line: 51, column: 3, scope: !98)587!100 = distinct !{!100, !101, !96, !102}588!101 = !DILocation(line: 51, column: 3, scope: !34)589!102 = !{!"llvm.loop.mustprogress"}590!103 = !DILocation(line: 58, column: 3, scope: !34)591