blob: e122db108369e74cf1634319d96ae0e1d1bd0e43 [file] [log] [blame]
Richard Smith8654ae52018-10-10 23:13:35 +00001// 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
2// RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap.proftext
3// 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
4
5namespace Foo {
6 struct X {};
7 bool cond();
8 void bar();
9 void baz();
10 void function(X x) {
11 if (cond())
12 bar();
13 else
14 baz();
15 }
16}
17
18// CHECK: define {{.*}} @_ZN3Foo8functionENS_1XE() {{.*}} !prof [[FUNC_ENTRY:![0-9]*]]
19// CHECK: br i1 {{.*}} !prof [[BR_WEIGHTS:![0-9]*]]
20//
21// FIXME: Laplace's rule of succession is applied to sample profiles...
22// CHECK-SAMPLES-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 1}
23// CHECK-SAMPLES-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 11, i32 91}
24//
25// ... but not to instruction profiles.
26// CHECK-INSTR-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 100}
27// CHECK-INSTR-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 10, i32 90}