|
| 1 | +; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals |
| 2 | +; RUN: opt -S -passes=pgo-instr-gen,instrprof < %s | FileCheck %s |
| 3 | + |
| 4 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 5 | +target triple = "x86_64-unknown-linux-gnu" |
| 6 | + |
| 7 | +;; Test that we use private aliases to reference function addresses inside profile data |
| 8 | +; CHECK: @__profd_foo = private global {{.*}}, ptr @foo.1, |
| 9 | +; CHECK-NOT: @__profd_foo = private global {{.*}}, ptr @foo, |
| 10 | +; CHECK: @[[__PROFC_WEAK:[a-zA-Z0-9_$"\\.-]+]] = weak hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8 |
| 11 | +; CHECK: @[[__PROFD_WEAK:[a-zA-Z0-9_$"\\.-]+]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 -5028622335731970946, i64 742261418966908927, i64 sub (i64 ptrtoint (ptr @__profc_weak to i64), i64 ptrtoint (ptr @__profd_weak to i64)), ptr @weak.2, ptr null, i32 1, [2 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profc_weak), align 8 |
| 12 | +; CHECK: @[[__PROFC_LINKONCE:[a-zA-Z0-9_$"\\.-]+]] = linkonce hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8 |
| 13 | +; CHECK: @[[__PROFD_LINKONCE:[a-zA-Z0-9_$"\\.-]+]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 -121947654961992603, i64 742261418966908927, i64 sub (i64 ptrtoint (ptr @__profc_linkonce to i64), i64 ptrtoint (ptr @__profd_linkonce to i64)), ptr @linkonce.3, ptr null, i32 1, [2 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profc_linkonce), align 8 |
| 14 | +; CHECK: @[[__PROFC_WEAKODR:[a-zA-Z0-9_$"\\.-]+]] = weak_odr hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8 |
| 15 | +; CHECK: @[[__PROFD_WEAKODR:[a-zA-Z0-9_$"\\.-]+]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 -4807837289933096997, i64 742261418966908927, i64 sub (i64 ptrtoint (ptr @__profc_weakodr to i64), i64 ptrtoint (ptr @__profd_weakodr to i64)), ptr @weakodr.4, ptr null, i32 1, [2 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profc_weakodr), align 8 |
| 16 | +; CHECK: @[[__PROFC_LINKONCEODR:[a-zA-Z0-9_$"\\.-]+]] = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8 |
| 17 | +; CHECK: @[[__PROFD_LINKONCEODR:[a-zA-Z0-9_$"\\.-]+]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 4214081367395809689, i64 742261418966908927, i64 sub (i64 ptrtoint (ptr @__profc_linkonceodr to i64), i64 ptrtoint (ptr @__profd_linkonceodr to i64)), ptr @linkonceodr.5, ptr null, i32 1, [2 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profc_linkonceodr), align 8 |
| 18 | +; CHECK: @[[__PROFC_AVAILABLE_EXTERNALLY_742261418966908927:[a-zA-Z0-9_$"\\.-]+]] = linkonce_odr hidden global [1 x i64] zeroinitializer, section "__llvm_prf_cnts", comdat, align 8 |
| 19 | +; CHECK: @[[__PROFD_AVAILABLE_EXTERNALLY_742261418966908927:[a-zA-Z0-9_$"\\.-]+]] = private global { i64, i64, i64, ptr, ptr, i32, [2 x i16] } { i64 -8510055422695886042, i64 742261418966908927, i64 sub (i64 ptrtoint (ptr @__profc_available_externally.742261418966908927 to i64), i64 ptrtoint (ptr @__profd_available_externally.742261418966908927 to i64)), ptr null, ptr null, i32 1, [2 x i16] zeroinitializer }, section "__llvm_prf_data", comdat($__profc_available_externally.742261418966908927), align 8 |
| 20 | + |
| 21 | +;; Ensure when not instrumenting a non-comdat function, then if we generate an |
| 22 | +;; alias, then it is private. We check comdat versions in comdat.ll |
| 23 | +; CHECK: @foo.1 = private alias i32 (i32), ptr @foo |
| 24 | +; CHECK: @[[WEAK_2:[a-zA-Z0-9_$"\\.-]+]] = private alias void (), ptr @weak |
| 25 | +; CHECK: @[[LINKONCE_3:[a-zA-Z0-9_$"\\.-]+]] = private alias void (), ptr @linkonce |
| 26 | +; CHECK: @[[WEAKODR_4:[a-zA-Z0-9_$"\\.-]+]] = private alias void (), ptr @weakodr |
| 27 | +; CHECK: @[[LINKONCEODR_5:[a-zA-Z0-9_$"\\.-]+]] = private alias void (), ptr @linkonceodr |
| 28 | + |
| 29 | +;; We should never generate an alias for available_externally functions |
| 30 | +; CHECK-NOT: @[[AVAILABLE_EXTERNALLY_6:[a-zA-Z0-9_$"\\.-]+]] = private alias void (), ptr @available_externally |
| 31 | + |
| 32 | +define i32 @foo(i32 %0) { |
| 33 | +; CHECK-LABEL: @foo( |
| 34 | +; CHECK-NEXT: entry: |
| 35 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_foo, align 8 |
| 36 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 37 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_foo, align 8 |
| 38 | +; CHECK-NEXT: ret i32 0 |
| 39 | +entry: |
| 40 | + ret i32 0 |
| 41 | +} |
| 42 | + |
| 43 | +define weak void @weak() { |
| 44 | +; CHECK-LABEL: @weak( |
| 45 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_weak, align 8 |
| 46 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 47 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_weak, align 8 |
| 48 | +; CHECK-NEXT: ret void |
| 49 | + ret void |
| 50 | +} |
| 51 | + |
| 52 | +define linkonce void @linkonce() { |
| 53 | +; CHECK-LABEL: @linkonce( |
| 54 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_linkonce, align 8 |
| 55 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 56 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_linkonce, align 8 |
| 57 | +; CHECK-NEXT: ret void |
| 58 | + ret void |
| 59 | +} |
| 60 | + |
| 61 | +define weak_odr void @weakodr() { |
| 62 | +; CHECK-LABEL: @weakodr( |
| 63 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_weakodr, align 8 |
| 64 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 65 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_weakodr, align 8 |
| 66 | +; CHECK-NEXT: ret void |
| 67 | + ret void |
| 68 | +} |
| 69 | + |
| 70 | +define linkonce_odr void @linkonceodr() { |
| 71 | +; CHECK-LABEL: @linkonceodr( |
| 72 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_linkonceodr, align 8 |
| 73 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 74 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_linkonceodr, align 8 |
| 75 | +; CHECK-NEXT: ret void |
| 76 | + ret void |
| 77 | +} |
| 78 | + |
| 79 | +define available_externally void @available_externally(){ |
| 80 | +; CHECK-LABEL: @available_externally( |
| 81 | +; CHECK-NEXT: [[PGOCOUNT:%.*]] = load i64, ptr @__profc_available_externally.742261418966908927, align 8 |
| 82 | +; CHECK-NEXT: [[TMP1:%.*]] = add i64 [[PGOCOUNT]], 1 |
| 83 | +; CHECK-NEXT: store i64 [[TMP1]], ptr @__profc_available_externally.742261418966908927, align 8 |
| 84 | +; CHECK-NEXT: ret void |
| 85 | + ret void |
| 86 | +} |
0 commit comments