xref: /llvm-project/clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll (revision 9e280c47588bfaf008a5fb091cd47df92b9c4264)
1; REQUIRES: x86-registered-target
2
3;; Test that passing -supports-hot-cold-new to the thin link prevents memprof
4;; metadata and attributes from being removed from the distributed ThinLTO
5;; backend, and vice versa without passing -supports-hot-cold-new.
6
7;; First check with -supports-hot-cold-new.
8; RUN: opt -thinlto-bc %s >%t.o
9; RUN: llvm-lto2 run %t.o -save-temps \
10; RUN:  -supports-hot-cold-new \
11; RUN:  -thinlto-distributed-indexes \
12; RUN:  -r=%t.o,main,plx \
13; RUN:  -r=%t.o,_Znam, \
14; RUN:  -o %t.out
15
16;; Ensure that the index file reflects the -supports-hot-cold-new, as that is
17;; how the ThinLTO backend behavior is controlled.
18; RUN: llvm-dis %t.out.index.bc -o - | FileCheck %s --check-prefix=CHECK-INDEX-ON
19;; Flags are printed in decimal, but this corresponds to 0x161, and 0x100 is
20;; the value indicating -supports-hot-cold-new was enabled.
21; CHECK-INDEX-ON: flags: 353
22
23; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.o.thinlto.bc -save-temps=obj
24
25; RUN: llvm-dis %t.s.3.import.bc -o - | FileCheck %s --check-prefix=CHECK-IR
26; CHECK-IR: !memprof {{.*}} !callsite
27; CHECK-IR: "memprof"="cold"
28
29;; Next check without -supports-hot-cold-new, we should not perform
30;; context disambiguation, and we should strip memprof metadata and
31;; attributes before optimization during the distributed backend.
32; RUN: llvm-lto2 run %t.o -save-temps \
33; RUN:  -thinlto-distributed-indexes \
34; RUN:  -r=%t.o,main,plx \
35; RUN:  -r=%t.o,_Znam, \
36; RUN:  -o %t.out
37
38;; Ensure that the index file reflects not having -supports-hot-cold-new.
39; RUN: llvm-dis %t.out.index.bc -o - | FileCheck %s --check-prefix=CHECK-INDEX-OFF
40;; Flags are printed in decimal, but this corresponds to 0x61, without 0x100 set.
41; CHECK-INDEX-OFF: flags: 97
42
43; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -o %t1.o -x ir %t.o -c -fthinlto-index=%t.o.thinlto.bc -save-temps=obj
44
45; RUN: llvm-dis %t.s.3.import.bc -o - | FileCheck %s \
46; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \
47; RUN: --implicit-check-not "memprof"="cold"
48
49source_filename = "thinlto-distributed-supports-hot-cold-new.ll"
50target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
51target triple = "x86_64-unknown-linux-gnu"
52
53define i32 @main() #0 {
54entry:
55  %call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5
56  %call1 = call ptr @_Znam(i64 0) #1
57  ret i32 0
58}
59
60declare ptr @_Znam(i64)
61
62attributes #0 = { noinline optnone }
63attributes #1 = { "memprof"="cold" }
64
65!0 = !{!1, !3}
66!1 = !{!2, !"notcold"}
67!2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414}
68!3 = !{!4, !"cold"}
69!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178}
70!5 = !{i64 9086428284934609951}
71