104 lines · plain
1;; Test callsite context graph generation for simple call graph with2;; two memprof contexts and no inlining, where one callsite required for3;; cloning is missing (e.g. unmatched). Use this to test aggressive hinting4;; 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.o24; 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=SIZESUNHINTED32; 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.o36; 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=SIZESHINTED44; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IRHINTED45 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.o49; 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=REMARKSHINTED56; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IRHINTED57 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 cloning65 %call = call ptr @_Z3foov()66 %call1 = call ptr @_Z3foov()67 ret i32 068}69 70define internal ptr @_Z3foov() #0 {71entry:72 %call = call ptr @_Znam(i64 0), !memprof !2, !callsite !773 ret ptr null74}75 76declare ptr @_Znam(i64)77 78; uselistorder directives79uselistorder 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 cloning94; SIZESUNHINTED: Cold full allocation context 456 with total size 200 is NotColdCold after cloning95; SIZESUNHINTED: Cold full allocation context 789 with total size 300 is NotColdCold after cloning96 97; SIZESHINTED: NotCold full allocation context 123 with total size 100 is NotColdCold after cloning marked Cold due to cold byte percent98; SIZESHINTED: Cold full allocation context 456 with total size 200 is NotColdCold after cloning marked Cold due to cold byte percent99; SIZESHINTED: Cold full allocation context 789 with total size 300 is NotColdCold after cloning marked Cold due to cold byte percent100 101; REMARKSHINTED: call in clone _Z3foov marked with memprof allocation attribute cold102 103; IRHINTED: "memprof"="cold"104