1 ;; Test that passing -supports-hot-cold-new to the LTO link allows context
2 ;; disambiguation to proceed, and also prevents memprof metadata and attributes
3 ;; from being removed from the LTO backend, and vice versa without passing
4 ;; -supports-hot-cold-new.
6 ; RUN: split-file %s %t
8 ;; First check with -supports-hot-cold-new.
9 ; RUN: opt -thinlto-bc %t/main.ll >%t/main.o
10 ; RUN: opt -thinlto-bc %t/foo.ll >%t/foo.o
11 ; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
12 ; RUN: -supports-hot-cold-new \
13 ; RUN: -r=%t/main.o,main,plx \
14 ; RUN: -r=%t/main.o,bar,plx \
15 ; RUN: -r=%t/main.o,foo, \
16 ; RUN: -r=%t/main.o,_Znam, \
17 ; RUN: -r=%t/foo.o,foo,plx \
18 ; RUN: -r=%t/foo.o,_Znam, \
19 ; RUN: -memprof-dump-ccg \
21 ; RUN: -o %t.out 2>&1 | FileCheck %s --check-prefix=DUMP
22 ; DUMP: Callsite Context Graph:
24 ; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s --check-prefix=IR
26 ; IR: !memprof {{.*}} !callsite
27 ; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
29 ; IR: !memprof {{.*}} !callsite
30 ; IR: @_Znam(i64 0) #[[ATTR:[0-9]+]]
31 ; IR: attributes #[[ATTR]] = { "memprof"="cold" }
33 ;; Next check without -supports-hot-cold-new, we should not perform
34 ;; context disambiguation, and we should strip memprof metadata and
35 ;; attributes before optimization.
36 ; RUN: llvm-lto2 run %t/main.o %t/foo.o -enable-memprof-context-disambiguation \
37 ; RUN: -r=%t/main.o,main,plx \
38 ; RUN: -r=%t/main.o,bar,plx \
39 ; RUN: -r=%t/main.o,foo, \
40 ; RUN: -r=%t/main.o,_Znam, \
41 ; RUN: -r=%t/foo.o,foo,plx \
42 ; RUN: -r=%t/foo.o,_Znam, \
43 ; RUN: -memprof-dump-ccg \
45 ; RUN: -o %t.out 2>&1 | FileCheck %s --allow-empty \
46 ; RUN: --implicit-check-not "Callsite Context Graph:"
48 ; RUN: llvm-dis %t.out.1.3.import.bc -o - | FileCheck %s \
49 ; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
50 ; RUN: --implicit-check-not "memprof"="cold"
53 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
54 target triple = "x86_64-unknown-linux-gnu"
56 define i32 @main() #0 {
58 %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5
59 %call2 = call ptr @_Znam(i64 0) #1
70 declare ptr @_Znam(i64)
72 attributes #0 = { noinline optnone }
73 attributes #1 = { "memprof"="cold" }
76 !1 = !{!2, !"notcold"}
77 !2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
79 !4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
80 !5 = !{i64 9086428284934609951}
83 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
84 target triple = "x86_64-unknown-linux-gnu"
88 %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5
89 %call2 = call ptr @_Znam(i64 0) #1
93 declare ptr @_Znam(i64)
95 attributes #1 = { "memprof"="cold" }
98 !1 = !{!2, !"notcold"}
99 !2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
101 !4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
102 !5 = !{i64 9086428284934609951}