1;; Test to ensure a call to a different callee but with the same debug info 2;; (and therefore callsite metadata) as a subsequent call in the alloc context 3;; does not cause missing or incorrect cloning. This test is otherwise the same 4;; as memprof-basic.ll. 5 6;; -stats requires asserts 7; REQUIRES: asserts 8 9; RUN: opt -thinlto-bc %s >%t.o 10; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \ 11; RUN: -supports-hot-cold-new \ 12; RUN: -r=%t.o,main,plx \ 13; RUN: -r=%t.o,blah, \ 14; RUN: -r=%t.o,_Znam, \ 15; RUN: -memprof-verify-ccg -memprof-verify-nodes \ 16; RUN: -stats -pass-remarks=memprof-context-disambiguation -save-temps \ 17; RUN: -o %t.out 2>&1 | FileCheck %s \ 18; RUN: --check-prefix=STATS --check-prefix=STATS-BE --check-prefix=REMARKS 19 20; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR 21 22source_filename = "memprof-aliased-location2.ll" 23target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" 24target triple = "x86_64-unknown-linux-gnu" 25 26define i32 @main() #0 { 27entry: 28 %call = call ptr @_Z3foov(), !callsite !0 29 %call1 = call ptr @_Z3foov(), !callsite !1 30 ret i32 0 31} 32 33declare void @blah() 34 35define internal ptr @_Z3barv() #0 { 36entry: 37 %call = call ptr @_Znam(i64 0), !memprof !2, !callsite !7 38 ret ptr null 39} 40 41declare ptr @_Znam(i64) 42 43define internal ptr @_Z3bazv() #0 { 44entry: 45 %call = call ptr @_Z3barv(), !callsite !8 46 ;; Subsequent call to another callee but with the same debug location / callsite id 47 call void @blah(), !callsite !8 48 ret ptr null 49} 50 51define internal ptr @_Z3foov() #0 { 52entry: 53 %call = call ptr @_Z3bazv(), !callsite !9 54 ret ptr null 55} 56 57; uselistorder directives 58uselistorder ptr @_Z3foov, { 1, 0 } 59 60attributes #0 = { noinline optnone } 61 62!0 = !{i64 8632435727821051414} 63!1 = !{i64 -3421689549917153178} 64!2 = !{!3, !5} 65!3 = !{!4, !"notcold"} 66!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414} 67!5 = !{!6, !"cold"} 68!6 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178} 69!7 = !{i64 9086428284934609951} 70!8 = !{i64 -5964873800580613432} 71!9 = !{i64 2732490490862098848} 72 73; REMARKS: call in clone main assigned to call function clone _Z3foov.memprof.1 74; REMARKS: created clone _Z3barv.memprof.1 75; REMARKS: call in clone _Z3barv marked with memprof allocation attribute notcold 76; REMARKS: call in clone _Z3barv.memprof.1 marked with memprof allocation attribute cold 77; REMARKS: created clone _Z3bazv.memprof.1 78; REMARKS: call in clone _Z3bazv.memprof.1 assigned to call function clone _Z3barv.memprof.1 79; REMARKS: created clone _Z3foov.memprof.1 80; REMARKS: call in clone _Z3foov.memprof.1 assigned to call function clone _Z3bazv.memprof.1 81 82 83; IR: define {{.*}} @main 84;; The first call to foo does not allocate cold memory. It should call the 85;; original functions, which ultimately call the original allocation decorated 86;; with a "notcold" attribute. 87; IR: call {{.*}} @_Z3foov() 88;; The second call to foo allocates cold memory. It should call cloned functions 89;; which ultimately call a cloned allocation decorated with a "cold" attribute. 90; IR: call {{.*}} @_Z3foov.memprof.1() 91; IR: define internal {{.*}} @_Z3barv() 92; IR: call {{.*}} @_Znam(i64 0) #[[NOTCOLD:[0-9]+]] 93; IR: define internal {{.*}} @_Z3bazv() 94; IR: call {{.*}} @_Z3barv() 95; IR: define internal {{.*}} @_Z3foov() 96; IR: call {{.*}} @_Z3bazv() 97; IR: define internal {{.*}} @_Z3barv.memprof.1() 98; IR: call {{.*}} @_Znam(i64 0) #[[COLD:[0-9]+]] 99; IR: define internal {{.*}} @_Z3bazv.memprof.1() 100; IR: call {{.*}} @_Z3barv.memprof.1() 101; IR: define internal {{.*}} @_Z3foov.memprof.1() 102; IR: call {{.*}} @_Z3bazv.memprof.1() 103; IR: attributes #[[NOTCOLD]] = { "memprof"="notcold" } 104; IR: attributes #[[COLD]] = { "memprof"="cold" } 105 106 107; STATS: 1 memprof-context-disambiguation - Number of cold static allocations (possibly cloned) 108; STATS-BE: 1 memprof-context-disambiguation - Number of cold static allocations (possibly cloned) during ThinLTO backend 109; STATS: 1 memprof-context-disambiguation - Number of not cold static allocations (possibly cloned) 110; STATS-BE: 1 memprof-context-disambiguation - Number of not cold static allocations (possibly cloned) during ThinLTO backend 111; STATS-BE: 2 memprof-context-disambiguation - Number of allocation versions (including clones) during ThinLTO backend 112; STATS: 3 memprof-context-disambiguation - Number of function clones created during whole program analysis 113; STATS-BE: 3 memprof-context-disambiguation - Number of function clones created during ThinLTO backend 114; STATS-BE: 3 memprof-context-disambiguation - Number of functions that had clones created during ThinLTO backend 115; STATS-BE: 2 memprof-context-disambiguation - Maximum number of allocation versions created for an original allocation during ThinLTO backend 116; STATS-BE: 1 memprof-context-disambiguation - Number of original (not cloned) allocations with memprof profiles during ThinLTO backend 117