130 lines · plain
1;; Test fixup of largest cold contexts.2 3;; This case has multiple recursive cycles in the cold context, which can be4;; made non-recursive with the inlining in the code.5 6;; -stats requires asserts7; REQUIRES: asserts8 9;; Need context sizes in summary, so enable reporting.10; RUN: opt -thinlto-bc -memprof-report-hinted-sizes %s >%t.o11 12;; First try disabling detection of the largest cold contexts.13;; We will not get any cloning.14; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \15; RUN: -supports-hot-cold-new \16; RUN: -memprof-top-n-important=0 \17; RUN: -r=%t.o,E,plx \18; RUN: -r=%t.o,DB,plx \19; RUN: -r=%t.o,CB,plx \20; RUN: -r=%t.o,A,plx \21; RUN: -r=%t.o,main,plx \22; RUN: -r=%t.o,_Znam, \23; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \24; RUN: -pass-remarks=memprof-context-disambiguation \25; RUN: -o %t.out 2>&1 | FileCheck %s --implicit-check-not="created clone" \26; RUN: --implicit-check-not="Number of cold static allocations" \27; RUN: --implicit-check-not="Number of function clones" \28; RUN: --implicit-check-not="Number of important context ids" \29; RUN: --implicit-check-not="Number of fixup"30 31;; Allow default detection of the largest cold contexts, but disable fixup.32;; We should find 1 important context, but still not get cloning.33; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \34; RUN: -supports-hot-cold-new \35; RUN: -memprof-fixup-important=false \36; RUN: -r=%t.o,E,plx \37; RUN: -r=%t.o,DB,plx \38; RUN: -r=%t.o,CB,plx \39; RUN: -r=%t.o,A,plx \40; RUN: -r=%t.o,main,plx \41; RUN: -r=%t.o,_Znam, \42; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \43; RUN: -pass-remarks=memprof-context-disambiguation \44; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=TOPN1-NOFIXUP \45; RUN: --implicit-check-not="created clone" \46; RUN: --implicit-check-not="Number of cold static allocations" \47; RUN: --implicit-check-not="Number of function clones" \48; RUN: --implicit-check-not="Number of fixup"49 50; TOPN1-NOFIXUP: 1 memprof-context-disambiguation - Number of important context ids51 52;; Allow default detection of largest cold contexts, fixup is enabled by default.53;; This case should get fixup and cloning.54; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \55; RUN: -supports-hot-cold-new \56; RUN: -r=%t.o,E,plx \57; RUN: -r=%t.o,DB,plx \58; RUN: -r=%t.o,CB,plx \59; RUN: -r=%t.o,A,plx \60; RUN: -r=%t.o,main,plx \61; RUN: -r=%t.o,_Znam, \62; RUN: -memprof-verify-ccg -memprof-verify-nodes -stats \63; RUN: -pass-remarks=memprof-context-disambiguation \64; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=TOPN165 66; TOPN1: created clone E.memprof.167; TOPN1: call in clone E marked with memprof allocation attribute notcold68; TOPN1: call in clone E.memprof.1 marked with memprof allocation attribute cold69; TOPN1: created clone DB.memprof.170; TOPN1: call in clone DB.memprof.1 assigned to call function clone E.memprof.171; TOPN1: created clone CB.memprof.172; TOPN1: call in clone CB.memprof.1 assigned to call function clone DB.memprof.173; TOPN1: created clone A.memprof.174; TOPN1: call in clone A.memprof.1 assigned to call function clone CB.memprof.175; TOPN1: call in clone main assigned to call function clone A.memprof.176 77; TOPN1: 1 memprof-context-disambiguation - Number of contexts with fixed edges78; TOPN1: 2 memprof-context-disambiguation - Number of fixup edges added79; TOPN1: 1 memprof-context-disambiguation - Number of important context ids80 81target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"82target triple = "x86_64-unknown-linux-gnu"83 84define void @E() {85entry:86 %call = tail call ptr @_Znam(i64 10), !memprof !7, !callsite !1487 ret void88}89 90define void @DB() {91entry:92 tail call void @E(), !callsite !1793 ret void94}95 96define void @CB() {97entry:98 tail call void @DB(), !callsite !2299 ret void100}101 102define void @A() {103entry:104 tail call void @CB(), !callsite !20105 ret void106}107 108define i32 @main() {109entry:110 tail call void @A(), !callsite !25111 tail call void @A(), !callsite !27112 ret i32 0113}114 115declare ptr @_Znam(i64)116 117!7 = !{!8, !10}118!8 = !{!9, !"cold", !2}119!9 = !{i64 123, i64 234, i64 345, i64 234, i64 456, i64 234, i64 567, i64 678}120!2 = !{i64 12345, i64 200}121!10 = !{!11, !"notcold", !3}122!3 = !{i64 23456, i64 200}123!11 = !{i64 123, i64 234, i64 345, i64 234, i64 456, i64 234, i64 567, i64 789}124!14 = !{i64 123}125!17 = !{i64 234, i64 345}126!22 = !{i64 234, i64 456}127!20 = !{i64 234, i64 567}128!25 = !{i64 678}129!27 = !{i64 789}130