Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / profile-remap.cpp
blobb27f67da58ff93b3427dc9683088eb8c4b5d8b9a
1 // REQUIRES: x86-registered-target
2 //
3 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-sample-use=%S/Inputs/profile-remap.samples -fprofile-remapping-file=%S/Inputs/profile-remap.map -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 -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
6 // RUN: llvm-profdata merge -output %T.profdata %S/Inputs/profile-remap_entry.proftext
7 // RUN: %clang_cc1 -triple x86_64-linux-gnu -fprofile-instrument-use-path=%T.profdata -fprofile-remapping-file=%S/Inputs/profile-remap.map -O2 %s -emit-llvm -o - | FileCheck %s --check-prefixes=CHECK,CHECK-INSTR
9 namespace Foo {
10 struct X {};
11 bool cond();
12 void bar();
13 void baz();
14 void function(X x) {
15 if (cond())
16 bar();
17 else
18 baz();
22 // CHECK: define {{.*}} @_ZN3Foo8functionENS_1XE() {{.*}} !prof [[FUNC_ENTRY:![0-9]*]]
23 // CHECK: br i1 {{.*}} !prof [[BR_WEIGHTS:![0-9]*]]
25 // FIXME: Laplace's rule of succession is applied to sample profiles...
26 // CHECK-SAMPLES-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 1}
27 // CHECK-SAMPLES-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 11, i32 91}
29 // ... but not to instruction profiles.
30 // CHECK-INSTR-DAG: [[FUNC_ENTRY]] = !{!"function_entry_count", i64 100}
31 // CHECK-INSTR-DAG: [[BR_WEIGHTS]] = !{!"branch_weights", i32 10, i32 90}