1 ;; Test to make sure that missing tail call frames in memprof profiles are
2 ;; identified and cloned as needed for regular LTO.
4 ;; -stats requires asserts
7 ; RUN: opt -thinlto-bc %s >%t.o
8 ; 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=STATS
18 ; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR
20 ;; Try again but with distributed ThinLTO
21 ; 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, \
30 ; RUN: -o %t2.out 2>&1 | FileCheck %s --check-prefix=STATS
32 ;; Run ThinLTO backend
33 ; 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=IR
37 ; STATS: 2 memprof-context-disambiguation - Number of profiled callees found via tail calls
38 ; STATS: 4 memprof-context-disambiguation - Aggregate depth of profiled callees found via tail calls
39 ; STATS: 2 memprof-context-disambiguation - Maximum depth of profiled callees found via tail calls
41 source_filename = "memprof-tailcall.cc"
42 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
43 target triple = "x86_64-unknown-linux-gnu"
45 ; Function Attrs: noinline
46 ; IR-LABEL: @_Z3barv()
47 define ptr @_Z3barv() local_unnamed_addr #0 {
49 ; IR: call {{.*}} @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]
50 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !5
54 ; Function Attrs: nobuiltin allocsize(0)
55 declare ptr @_Znam(i64) #1
57 ; Function Attrs: noinline
58 ; IR-LABEL: @_Z3bazv()
59 define ptr @_Z3bazv() #0 {
61 ; IR: call ptr @_Z3barv()
62 %call = tail call ptr @_Z3barv()
66 ; Function Attrs: noinline
67 ; IR-LABEL: @_Z3foov()
68 define ptr @_Z3foov() #0 {
70 ; IR: call ptr @_Z3bazv()
71 %call = tail call ptr @_Z3bazv()
75 ; Function Attrs: noinline
77 define i32 @main() #0 {
78 ;; The first call to foo is part of a cold context, and should use the
79 ;; original functions.
80 ; IR: call ptr @_Z3foov()
81 %call = tail call ptr @_Z3foov(), !callsite !6
82 ;; The second call to foo is part of a cold context, and should call the
84 ; IR: call ptr @_Z3foov.memprof.1()
85 %call1 = tail call ptr @_Z3foov(), !callsite !7
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()
96 ; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }
97 ; IR: attributes #[[COLD]] = { builtin allocsize(0) "memprof"="cold" }
99 attributes #0 = { noinline }
100 attributes #1 = { nobuiltin allocsize(0) }
101 attributes #2 = { builtin allocsize(0) }
104 !1 = !{!2, !"notcold"}
105 !2 = !{i64 3186456655321080972, i64 8632435727821051414}
107 !4 = !{i64 3186456655321080972, i64 -3421689549917153178}
108 !5 = !{i64 3186456655321080972}
109 !6 = !{i64 8632435727821051414}
110 !7 = !{i64 -3421689549917153178}