1 ;; Test to make sure that missing tail call frames in memprof profiles are
2 ;; identified but not cloned when there are multiple non-unique possible
3 ;; tail call chains between the profiled frames.
5 ;; -stats requires asserts
8 ; RUN: opt -thinlto-bc %s >%t.o
9 ; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
10 ; RUN: -supports-hot-cold-new \
11 ; RUN: -r=%t.o,_Z3barv,plx \
12 ; RUN: -r=%t.o,_Z5blah1v,plx \
13 ; RUN: -r=%t.o,_Z5blah2v,plx \
14 ; RUN: -r=%t.o,_Z4baz1v,plx \
15 ; RUN: -r=%t.o,_Z4baz2v,plx \
16 ; RUN: -r=%t.o,_Z3foob,plx \
17 ; RUN: -r=%t.o,xyz,plx \
18 ; RUN: -r=%t.o,main,plx \
19 ; RUN: -r=%t.o,_Znam, \
20 ; RUN: -stats -debug -save-temps \
21 ; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=STATS --check-prefix=DEBUG
23 ; RUN: llvm-dis %t.out.1.4.opt.bc -o - | FileCheck %s --check-prefix=IR
25 ;; Try again but with distributed ThinLTO
26 ; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
27 ; RUN: -supports-hot-cold-new \
28 ; RUN: -thinlto-distributed-indexes \
29 ; RUN: -r=%t.o,_Z3barv,plx \
30 ; RUN: -r=%t.o,_Z5blah1v,plx \
31 ; RUN: -r=%t.o,_Z5blah2v,plx \
32 ; RUN: -r=%t.o,_Z4baz1v,plx \
33 ; RUN: -r=%t.o,_Z4baz2v,plx \
34 ; RUN: -r=%t.o,_Z3foob,plx \
35 ; RUN: -r=%t.o,xyz,plx \
36 ; RUN: -r=%t.o,main,plx \
37 ; RUN: -r=%t.o,_Znam, \
38 ; RUN: -stats -debug \
39 ; RUN: -o %t2.out 2>&1 | FileCheck %s --check-prefix=STATS --check-prefix=DEBUG
41 ;; Run ThinLTO backend
42 ; RUN: opt -passes=memprof-context-disambiguation \
43 ; RUN: -memprof-import-summary=%t.o.thinlto.bc \
44 ; RUN: -stats %t.o -S 2>&1 | FileCheck %s --check-prefix=IR
46 ; DEBUG: Not found through unique tail call chain: 17377440600225628772 (_Z3barv) from 15822663052811949562 (main) that actually called 8716735811002003409 (xyz) (found multiple possible chains)
48 ; STATS: 1 memprof-context-disambiguation - Number of profiled callees found via multiple tail call chains
50 ;; Check that all calls in the IR are to the original functions, leading to a
51 ;; non-cold operator new call.
53 source_filename = "tailcall-nonunique.cc"
54 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"
55 target triple = "x86_64-unknown-linux-gnu"
57 ; Function Attrs: noinline
58 ; IR-LABEL: @_Z3barv()
59 define dso_local ptr @_Z3barv() local_unnamed_addr #0 {
61 ; IR: call {{.*}} @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]
62 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !9
66 ; Function Attrs: nobuiltin allocsize(0)
67 declare ptr @_Znam(i64) #1
69 ; Function Attrs: noinline
70 ; IR-LABEL: @_Z5blah1v()
71 define dso_local ptr @_Z5blah1v() local_unnamed_addr #0 {
73 ; IR: call ptr @_Z3barv()
74 %call = tail call ptr @_Z3barv()
78 ; Function Attrs: noinline
79 ; IR-LABEL: @_Z5blah2v()
80 define dso_local ptr @_Z5blah2v() local_unnamed_addr #0 {
82 ; IR: call ptr @_Z3barv()
83 %call = tail call ptr @_Z3barv()
87 ; Function Attrs: noinline
88 ; IR-LABEL: @_Z4baz1v()
89 define dso_local ptr @_Z4baz1v() local_unnamed_addr #0 {
91 ; IR: call ptr @_Z5blah1v()
92 %call = tail call ptr @_Z5blah1v()
96 ; Function Attrs: noinline
97 ; IR-LABEL: @_Z4baz2v()
98 define dso_local ptr @_Z4baz2v() local_unnamed_addr #0 {
100 ; IR: call ptr @_Z5blah2v()
101 %call = tail call ptr @_Z5blah2v()
105 ; Function Attrs: noinline
106 ; IR-LABEL: @_Z3foob(i1 %b)
107 define dso_local ptr @_Z3foob(i1 %b) local_unnamed_addr #0 {
109 br i1 %b, label %if.then, label %if.else
111 if.then: ; preds = %entry
112 ; IR: call ptr @_Z4baz1v()
113 %call = tail call ptr @_Z4baz1v()
116 if.else: ; preds = %entry
117 ; IR: call ptr @_Z4baz2v()
118 %call1 = tail call ptr @_Z4baz2v()
121 return: ; preds = %if.else, %if.then
122 %retval.0 = phi ptr [ %call, %if.then ], [ %call1, %if.else ]
126 ; Function Attrs: noinline
128 define dso_local i32 @xyz() local_unnamed_addr #0 {
130 ; IR: call ptr @_Z3foob(i1 true)
131 %call = tail call ptr @_Z3foob(i1 true)
132 ; IR: call ptr @_Z3foob(i1 true)
133 %call1 = tail call ptr @_Z3foob(i1 true)
134 ; IR: call ptr @_Z3foob(i1 false)
135 %call2 = tail call ptr @_Z3foob(i1 false)
136 ; IR: call ptr @_Z3foob(i1 false)
137 %call3 = tail call ptr @_Z3foob(i1 false)
141 define dso_local i32 @main() local_unnamed_addr #0 {
143 ; IR: call i32 @xyz()
144 %call1 = tail call i32 @xyz(), !callsite !11
148 ; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }
150 attributes #0 = { noinline }
151 attributes #1 = { nobuiltin allocsize(0) }
152 attributes #2 = { builtin allocsize(0) }
155 !5 = !{!6, !"notcold"}
156 !6 = !{i64 3186456655321080972, i64 8632435727821051414}
158 !8 = !{i64 3186456655321080972, i64 -3421689549917153178}
159 !9 = !{i64 3186456655321080972}
160 !11 = !{i64 -3421689549917153178}