1 ;; Test to ensure a call to a different callee but with the same debug info
2 ;; (and therefore callsite metadata) as a subsequent tail call in the alloc
3 ;; context does not cause missing or incorrect cloning. This test is otherwise
4 ;; the same as tailcall.ll.
6 ;; -stats requires asserts
9 ; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
10 ; RUN: -stats %s -S 2>&1 | FileCheck %s --check-prefix=STATS --check-prefix=IR
12 source_filename = "tailcall-aliased-location2.cc"
13 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"
14 target triple = "x86_64-unknown-linux-gnu"
16 @a = dso_local global [2 x ptr] [ptr @_Z2a1v, ptr @_Z2a2v], align 16
18 declare void @_Z2a1v() #0
20 declare void @_Z2a2v() #0
22 ; Function Attrs: noinline
23 ; IR-LABEL: @_Z3barv()
24 define ptr @_Z3barv() local_unnamed_addr #0 {
26 ; IR: call ptr @_Znam(i64 10) #[[NOTCOLD:[0-9]+]]
27 %call = tail call ptr @_Znam(i64 10) #2, !memprof !0, !callsite !5
31 ; Function Attrs: nobuiltin allocsize(0)
32 declare ptr @_Znam(i64) #1
35 ; Function Attrs: noinline
36 ; IR-LABEL: @_Z3bazv()
37 define ptr @_Z3bazv() #0 {
39 ; IR: call ptr @_Z3barv()
40 %call = tail call ptr @_Z3barv()
44 ; Function Attrs: noinline
45 ; IR-LABEL: @_Z3foov()
46 define ptr @_Z3foov() #0 {
48 ; IR: call ptr @_Z3bazv()
49 %call = tail call ptr @_Z3bazv()
53 ; Function Attrs: noinline
55 define i32 @main() #0 {
56 ;; The first call to foo is part of a cold context, and should use the
57 ;; original functions.
58 ;; allocation. The latter should call the cloned functions.
59 ; IR: call ptr @_Z3foov()
60 %call = tail call ptr @_Z3foov(), !callsite !6
61 ;; Subsequent call to another callee but with the same debug location / callsite id
62 call void @blah(), !callsite !6
63 ;; The second call to foo is part of a cold context, and should call the
65 ; IR: call ptr @_Z3foov.memprof.1()
66 %call1 = tail call ptr @_Z3foov(), !callsite !7
67 %2 = load ptr, ptr @a, align 16
68 call void %2(), !callsite !10
72 ; IR-LABEL: @_Z3barv.memprof.1()
73 ; IR: call ptr @_Znam(i64 10) #[[COLD:[0-9]+]]
74 ; IR-LABEL: @_Z3bazv.memprof.1()
75 ; IR: call ptr @_Z3barv.memprof.1()
76 ; IR-LABEL: @_Z3foov.memprof.1()
77 ; IR: call ptr @_Z3bazv.memprof.1()
79 ; IR: attributes #[[NOTCOLD]] = { builtin allocsize(0) "memprof"="notcold" }
80 ; IR: attributes #[[COLD]] = { builtin allocsize(0) "memprof"="cold" }
82 ; STATS: 2 memprof-context-disambiguation - Number of profiled callees found via tail calls
83 ; STATS: 4 memprof-context-disambiguation - Aggregate depth of profiled callees found via tail calls
84 ; STATS: 2 memprof-context-disambiguation - Maximum depth of profiled callees found via tail calls
86 attributes #0 = { noinline }
87 attributes #1 = { nobuiltin allocsize(0) }
88 attributes #2 = { builtin allocsize(0) }
91 !1 = !{!2, !"notcold"}
92 !2 = !{i64 3186456655321080972, i64 8632435727821051414}
94 !4 = !{i64 3186456655321080972, i64 -3421689549917153178}
95 !5 = !{i64 3186456655321080972}
96 !6 = !{i64 8632435727821051414}
97 !7 = !{i64 -3421689549917153178}
98 !8 = !{!9, !"notcold"}
99 !9 = !{i64 3186456655321080972, i64 1}