111 lines · plain
1;; Test to make sure that missing tail call frames in memprof profiles are2;; identified and cloned as needed for regular LTO.3 4;; -stats requires asserts5; REQUIRES: asserts6 7; RUN: opt -thinlto-bc %s >%t.o8; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \9; RUN: -supports-hot-cold-new \10; RUN: -r=%t.o,_Z3barv,plx \11; RUN: -r=%t.o,_Z3bazv,plx \12; RUN: -r=%t.o,_Z3foov,plx \13; RUN: -r=%t.o,main,plx \14; RUN: -r=%t.o,_Znam, \15; RUN: -stats -save-temps \16; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=STATS17 18; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR19 20;; Try again but with distributed ThinLTO21; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \22; RUN: -supports-hot-cold-new \23; RUN: -thinlto-distributed-indexes \24; RUN: -r=%t.o,_Z3barv,plx \25; RUN: -r=%t.o,_Z3bazv,plx \26; RUN: -r=%t.o,_Z3foov,plx \27; RUN: -r=%t.o,main,plx \28; RUN: -r=%t.o,_Znam, \29; RUN: -stats \30; RUN: -o %t2.out 2>&1 | FileCheck %s --check-prefix=STATS31 32;; Run ThinLTO backend33; RUN: opt -passes=memprof-context-disambiguation \34; RUN: -memprof-import-summary=%t.o.thinlto.bc \35; RUN: -stats %t.o -S 2>&1 | FileCheck %s --check-prefix=IR36 37; STATS: 2 memprof-context-disambiguation - Number of profiled callees found via tail calls38; STATS: 4 memprof-context-disambiguation - Aggregate depth of profiled callees found via tail calls39; STATS: 2 memprof-context-disambiguation - Maximum depth of profiled callees found via tail calls40 41source_filename = "memprof-tailcall.cc"42target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"43target triple = "x86_64-unknown-linux-gnu"44 45; Function Attrs: noinline46; IR-LABEL: @_Z3barv()47define ptr @_Z3barv() local_unnamed_addr #0 {48entry:49 ; IR: call {{.*}} @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]50 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !551 ret ptr %call52}53 54; Function Attrs: nobuiltin allocsize(0)55declare ptr @_Znam(i64) #156 57; Function Attrs: noinline58; IR-LABEL: @_Z3bazv()59define ptr @_Z3bazv() #0 {60entry:61 ; IR: call ptr @_Z3barv()62 %call = tail call ptr @_Z3barv()63 ret ptr %call64}65 66; Function Attrs: noinline67; IR-LABEL: @_Z3foov()68define ptr @_Z3foov() #0 {69entry:70 ; IR: call ptr @_Z3bazv()71 %call = tail call ptr @_Z3bazv()72 ret ptr %call73}74 75; Function Attrs: noinline76; IR-LABEL: @main()77define i32 @main() #0 {78 ;; The first call to foo is part of a cold context, and should use the79 ;; original functions.80 ; IR: call ptr @_Z3foov()81 %call = tail call ptr @_Z3foov(), !callsite !682 ;; The second call to foo is part of a cold context, and should call the83 ;; cloned functions.84 ; IR: call ptr @_Z3foov.memprof.1()85 %call1 = tail call ptr @_Z3foov(), !callsite !786 ret i32 087}88 89; IR-LABEL: @_Z3barv.memprof.1()90; IR: call {{.*}} @_Znam(i64 10) #[[COLD:[0-9]+]]91; IR-LABEL: @_Z3bazv.memprof.1()92; IR: call ptr @_Z3barv.memprof.1()93; IR-LABEL: @_Z3foov.memprof.1()94; IR: call ptr @_Z3bazv.memprof.1()95 96; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }97; IR: attributes #[[COLD]] = { builtin allocsize(0) "memprof"="cold" }98 99attributes #0 = { noinline }100attributes #1 = { nobuiltin allocsize(0) }101attributes #2 = { builtin allocsize(0) }102 103!0 = !{!1, !3}104!1 = !{!2, !"notcold"}105!2 = !{i64 3186456655321080972, i64 8632435727821051414}106!3 = !{!4, !"cold"}107!4 = !{i64 3186456655321080972, i64 -3421689549917153178}108!5 = !{i64 3186456655321080972}109!6 = !{i64 8632435727821051414}110!7 = !{i64 -3421689549917153178}111