117 lines · plain
1;; Test to ensure a call to a different callee but with the same debug info2;; (and therefore callsite metadata) as a subsequent call in the alloc context3;; does not cause missing or incorrect cloning. This test is otherwise the same4;; as memprof-basic.ll.5 6;; -stats requires asserts7; REQUIRES: asserts8 9; RUN: opt -thinlto-bc %s >%t.o10; 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=REMARKS19 20; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR21 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 !029 %call1 = call ptr @_Z3foov(), !callsite !130 ret i32 031}32 33declare void @blah()34 35define internal ptr @_Z3barv() #0 {36entry:37 %call = call ptr @_Znam(i64 0), !memprof !2, !callsite !738 ret ptr null39}40 41declare ptr @_Znam(i64)42 43define internal ptr @_Z3bazv() #0 {44entry:45 %call = call ptr @_Z3barv(), !callsite !846 ;; Subsequent call to another callee but with the same debug location / callsite id47 call void @blah(), !callsite !848 ret ptr null49}50 51define internal ptr @_Z3foov() #0 {52entry:53 %call = call ptr @_Z3bazv(), !callsite !954 ret ptr null55}56 57; uselistorder directives58uselistorder 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.174; REMARKS: created clone _Z3barv.memprof.175; REMARKS: call in clone _Z3barv marked with memprof allocation attribute notcold76; REMARKS: call in clone _Z3barv.memprof.1 marked with memprof allocation attribute cold77; REMARKS: created clone _Z3bazv.memprof.178; REMARKS: call in clone _Z3bazv.memprof.1 assigned to call function clone _Z3barv.memprof.179; REMARKS: created clone _Z3foov.memprof.180; REMARKS: call in clone _Z3foov.memprof.1 assigned to call function clone _Z3bazv.memprof.181 82 83; IR: define {{.*}} @main84;; The first call to foo does not allocate cold memory. It should call the85;; original functions, which ultimately call the original allocation decorated86;; with a "notcold" attribute.87; IR: call {{.*}} @_Z3foov()88;; The second call to foo allocates cold memory. It should call cloned functions89;; 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 backend109; 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 backend111; STATS-BE: 2 memprof-context-disambiguation - Number of allocation versions (including clones) during ThinLTO backend112; STATS: 3 memprof-context-disambiguation - Number of function clones created during whole program analysis113; STATS-BE: 3 memprof-context-disambiguation - Number of function clones created during ThinLTO backend114; STATS-BE: 3 memprof-context-disambiguation - Number of functions that had clones created during ThinLTO backend115; STATS-BE: 2 memprof-context-disambiguation - Maximum number of allocation versions created for an original allocation during ThinLTO backend116; STATS-BE: 1 memprof-context-disambiguation - Number of original (not cloned) allocations with memprof profiles during ThinLTO backend117