| 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.4.opt.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.4.opt.bc -o - | FileCheck %s \ |
| 46 |
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \ |
| 47 |
; RUN: --implicit-check-not "memprof"="cold" |
| 48 |
|
| 49 |
;; Ensure the attributes and metadata are stripped when running a non-LTO pipeline. |
| 50 |
; RUN: %clang -target x86_64-unknown-linux-gnu -O2 -x ir %t.o -S -emit-llvm -o - | FileCheck %s \ |
| 51 |
; RUN: --implicit-check-not "!memprof" --implicit-check-not "!callsite" \ |
| 52 |
; RUN: --implicit-check-not "memprof"="cold" |
| 53 |
|
| 54 |
source_filename = "thinlto-distributed-supports-hot-cold-new.ll" |
| 55 |
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 56 |
target triple = "x86_64-unknown-linux-gnu" |
| 57 |
|
| 58 |
define i32 @main() #0 { |
| 59 |
entry: |
| 60 |
%call = call ptr @_Znam(i64 0), !memprof !0, !callsite !5 |
| 61 |
%call1 = call ptr @_Znam(i64 0) #1 |
| 62 |
ret i32 0 |
| 63 |
} |
| 64 |
|
| 65 |
declare ptr @_Znam(i64) |
| 66 |
|
| 67 |
attributes #0 = { noinline optnone } |
| 68 |
attributes #1 = { "memprof"="cold" } |
| 69 |
|
| 70 |
!0 = !{!1, !3} |
| 71 |
!1 = !{!2, !"notcold"} |
| 72 |
!2 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 8632435727821051414} |
| 73 |
!3 = !{!4, !"cold"} |
| 74 |
!4 = !{i64 9086428284934609951, i64 -5964873800580613432, i64 2732490490862098848, i64 -3421689549917153178} |
| 75 |
!5 = !{i64 9086428284934609951} |