blob: 0fc7c7b40033e282a2ca6a12d6e9a60b917990d5 [file] [log] [blame]
Yvan Roux84b52a22018-10-16 08:47:36 +00001// REQUIRES: x86-registered-target
2//
Richard Smith8654ae52018-10-10 23:13:35 +00003// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-sample-use=%S/Inputs/profile-remap.samples -fprofile-remapping-file=%S/Inputs/profile-remap.map -fexperimental-new-pass-manager -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-SAMPLES
4// RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap.proftext
5// RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%T.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -fexperimental-new-pass-manager -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
6
7namespace Foo {
8 struct X {};
9 bool cond();
10 void bar();
11 void baz();
12 void function(X x) {
13 if (cond())
14 bar();
15 else
16 baz();
17 }
18}
19
20// CHECK: define {{.*}} @_ZN3Foo8functionENS_1XE() {{.*}} !prof [[FUNC_ENTRY:![0-9]*]]
21// CHECK: br i1 {{.*}} !prof [[BR_WEIGHTS:![0-9]*]]
22//
23// FIXME: Laplace's rule of succession is applied to sample profiles...
24// CHECK-SAMPLES-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 1}
25// CHECK-SAMPLES-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 11, i32 91}
26//
27// ... but not to instruction profiles.
28// CHECK-INSTR-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 100}
29// CHECK-INSTR-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 10, i32 90}