llvm-project/clang/test/Profile/cxx-templates.cpp
Rong Xu 9c6f1538cc [PGO] Change profile use cc1 option to handle IR level profiles
This patch changes cc1 option for PGO profile use from
-fprofile-instr-use=<path> to -fprofile-instrument-use-path=<path>.
-fprofile-instr-use=<path> is now a driver only option.

In addition to decouple the cc1 option from the driver level option, this patch
also enables IR level profile use. cc1 option handling now reads the profile
header and sets CodeGenOpt ProfileUse (valid values are {None, Clang, LLVM}
-- this is a common enum for -fprofile-instrument={}, for the profile
instrumentation), and invoke the pipeline to enable the respective PGO use pass.

Reviewers: silvas, davidxl

Differential Revision: http://reviews.llvm.org/D17737

llvm-svn: 262515
2016-03-02 20:59:36 +00:00

43 lines
1.9 KiB
C++

// Tests for instrumentation of templated code. Each instantiation of a template
// should be instrumented separately.
// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument=clang > %tgen
// RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s
// RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
// RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
// RUN: %clang_cc1 -x c++ %s -triple %itanium_abi_triple -main-file-name cxx-templates.cpp -std=c++11 -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata > %tuse
// RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
// RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer
// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr hidden global [2 x i64] zeroinitializer
// T0GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()
// T0USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj0EEvv()
// T100GEN-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv()
// T100USE-LABEL: define linkonce_odr {{.*}}void @_Z4loopILj100EEvv()
template <unsigned N> void loop() {
// ALL-NOT: ret
// T0GEN: store {{.*}} @[[T0C]], i64 0, i64 0
// T100GEN: store {{.*}} @[[T100C]], i64 0, i64 0
// ALL-NOT: ret
// T0GEN: store {{.*}} @[[T0C]], i64 0, i64 1
// T0USE: br {{.*}} !prof ![[T01:[0-9]+]]
// T100GEN: store {{.*}} @[[T100C]], i64 0, i64 1
// T100USE: br {{.*}} !prof ![[T1001:[0-9]+]]
for (unsigned I = 0; I < N; ++I) {}
// ALL: ret
}
// T0USE-DAG: ![[T01]] = !{!"branch_weights", i32 1, i32 2}
// T100USE-DAG: ![[T1001]] = !{!"branch_weights", i32 101, i32 2}
int main(int argc, const char *argv[]) {
loop<0>();
loop<100>();
return 0;
}