xref: /llvm-project/llvm/test/ThinLTO/X86/memprof-missing-callsite.ll (revision c7451ffcb94a1fe53b703e9fc3204bf6cda610a9)
1;; Test callsite context graph generation for simple call graph with
2;; two memprof contexts and no inlining, where one callsite required for
3;; cloning is missing (e.g. unmatched). Use this to test aggressive hinting
4;; threshold.
5;;
6;; Original code looks like:
7;;
8;; char *foo() {
9;;   return new char[10];
10;; }
11;;
12;; int main(int argc, char **argv) {
13;;   char *x = foo();
14;;   char *y = foo();
15;;   memset(x, 0, 10);
16;;   memset(y, 0, 10);
17;;   delete[] x;
18;;   sleep(200);
19;;   delete[] y;
20;;   return 0;
21;; }
22
23; RUN: opt -thinlto-bc -memprof-report-hinted-sizes %s >%t.o
24; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
25; RUN:	-supports-hot-cold-new \
26; RUN:	-r=%t.o,main,plx \
27; RUN:	-r=%t.o,_Znam, \
28; RUN:	-memprof-report-hinted-sizes \
29; RUN:	-pass-remarks=memprof-context-disambiguation -save-temps \
30; RUN:	-o %t.out 2>&1 | FileCheck %s --implicit-check-not "call in clone _Z3foov" \
31; RUN:  --check-prefix=SIZESUNHINTED
32; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --implicit-check-not "\"memprof\"=\"cold\""
33
34;; Check that we do hint with a sufficient -memprof-cloning-cold-threshold.
35; RUN: opt -thinlto-bc -memprof-report-hinted-sizes %s >%t.o
36; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
37; RUN:	-supports-hot-cold-new \
38; RUN:	-r=%t.o,main,plx \
39; RUN:	-r=%t.o,_Znam, \
40; RUN:	-memprof-report-hinted-sizes -memprof-cloning-cold-threshold=80 \
41; RUN:	-pass-remarks=memprof-context-disambiguation -save-temps \
42; RUN:	-o %t.out 2>&1 | FileCheck %s --check-prefix=REMARKSHINTED \
43; RUN:  --check-prefix=SIZESHINTED
44; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IRHINTED
45
46;; Check again that we hint with a sufficient -memprof-cloning-cold-threshold,
47;; even if we don't specify -memprof-report-hinted-sizes.
48; RUN: opt -thinlto-bc -memprof-report-hinted-sizes %s >%t.o
49; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
50; RUN:	-supports-hot-cold-new \
51; RUN:	-r=%t.o,main,plx \
52; RUN:	-r=%t.o,_Znam, \
53; RUN:	-memprof-cloning-cold-threshold=80 \
54; RUN:	-pass-remarks=memprof-context-disambiguation -save-temps \
55; RUN:	-o %t.out 2>&1 | FileCheck %s --check-prefix=REMARKSHINTED
56; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IRHINTED
57
58source_filename = "memprof-missing-callsite.ll"
59target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
60target triple = "x86_64-unknown-linux-gnu"
61
62define i32 @main() #0 {
63entry:
64  ;; Missing callsite metadata blocks cloning
65  %call = call ptr @_Z3foov()
66  %call1 = call ptr @_Z3foov()
67  ret i32 0
68}
69
70define internal ptr @_Z3foov() #0 {
71entry:
72  %call = call ptr @_Znam(i64 0), !memprof !2, !callsite !7
73  ret ptr null
74}
75
76declare ptr @_Znam(i64)
77
78; uselistorder directives
79uselistorder ptr @_Z3foov, { 1, 0 }
80
81attributes #0 = { noinline optnone }
82
83!2 = !{!3, !5}
84!3 = !{!4, !"notcold", !10}
85!4 = !{i64 9086428284934609951, i64 8632435727821051414}
86!5 = !{!6, !"cold", !11, !12}
87!6 = !{i64 9086428284934609951, i64 -3421689549917153178}
88!7 = !{i64 9086428284934609951}
89!10 = !{i64 123, i64 100}
90!11 = !{i64 456, i64 200}
91!12 = !{i64 789, i64 300}
92
93; SIZESUNHINTED: NotCold full allocation context 123 with total size 100 is NotColdCold after cloning
94; SIZESUNHINTED: Cold full allocation context 456 with total size 200 is NotColdCold after cloning
95; SIZESUNHINTED: Cold full allocation context 789 with total size 300 is NotColdCold after cloning
96
97; SIZESHINTED: NotCold full allocation context 123 with total size 100 is NotColdCold after cloning marked Cold due to cold byte percent
98; SIZESHINTED: Cold full allocation context 456 with total size 200 is NotColdCold after cloning marked Cold due to cold byte percent
99; SIZESHINTED: Cold full allocation context 789 with total size 300 is NotColdCold after cloning marked Cold due to cold byte percent
100
101; REMARKSHINTED: call in clone _Z3foov marked with memprof allocation attribute cold
102
103; IRHINTED: "memprof"="cold"
104