1 ;; Test handling of memprof distributed ThinLTO when the call to update is an alias.
3 ;; Preparation steps to generate the bitcode and perform the thin link.
4 ; RUN: opt -thinlto-bc %s >%t.o
5 ; RUN: llvm-lto2 run %t.o -enable-memprof-context-disambiguation \
6 ; RUN: -supports-hot-cold-new \
7 ; RUN: -thinlto-distributed-indexes \
8 ; RUN: -r=%t.o,main,plx \
9 ; RUN: -r=%t.o,_Znam, \
12 ;; Run ThinLTO backend
13 ; RUN: opt -passes=memprof-context-disambiguation \
14 ; RUN: -memprof-import-summary=%t.o.thinlto.bc \
15 ; RUN: -pass-remarks=memprof-context-disambiguation \
16 ; RUN: %t.o -S 2>&1 | FileCheck %s --check-prefix=IR
18 source_filename = "memprof-distrib-alias.ll"
19 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
20 target triple = "x86_64-unknown-linux-gnu"
22 define i32 @main() #0 {
24 ;; The first call to fooAlias does not allocate cold memory. It should call
25 ;; the original function alias, which calls the original allocation decorated
26 ;; with a "notcold" attribute.
27 ; IR: call {{.*}} @_Z8fooAliasv()
28 %call = call ptr @_Z8fooAliasv(), !callsite !0
29 ;; The second call to fooAlias allocates cold memory. It should call the
30 ;; cloned function which calls a cloned allocation decorated with a "cold"
32 ; IR: call {{.*}} @_Z3foov.memprof.1()
33 %call1 = call ptr @_Z8fooAliasv(), !callsite !1
37 ; IR: define internal {{.*}} @_Z3foov()
38 ; IR: call {{.*}} @_Znam(i64 0) #[[NOTCOLD:[0-9]+]]
39 ; IR: define internal {{.*}} @_Z3foov.memprof.1()
40 ; IR: call {{.*}} @_Znam(i64 0) #[[COLD:[0-9]+]]
41 ; IR: attributes #[[NOTCOLD]] = { "memprof"="notcold" }
42 ; IR: attributes #[[COLD]] = { "memprof"="cold" }
44 declare ptr @_Znam(i64)
46 @_Z8fooAliasv = internal alias ptr (...), ptr @_Z3foov
48 define internal ptr @_Z3foov() #0 {
50 %call = call ptr @_Znam(i64 0), !memprof !2, !callsite !7
54 attributes #0 = { noinline optnone }
56 !0 = !{i64 8632435727821051414}
57 !1 = !{i64 -3421689549917153178}
59 !3 = !{!4, !"notcold"}
60 !4 = !{i64 9086428284934609951, i64 8632435727821051414}
62 !6 = !{i64 9086428284934609951, i64 -3421689549917153178}
63 !7 = !{i64 9086428284934609951}