2014-04-12 08:54:06 +08:00
|
|
|
// Tests for instrumentation of templated code. Each instantiation of a template
|
|
|
|
// should be instrumented separately.
|
|
|
|
|
2016-02-05 02:39:09 +08:00
|
|
|
// 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
|
2014-04-12 08:54:06 +08:00
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=T0GEN -check-prefix=ALL %s
|
|
|
|
// RUN: FileCheck --input-file=%tgen -check-prefix=T100GEN -check-prefix=ALL %s
|
|
|
|
|
2014-04-18 06:49:06 +08:00
|
|
|
// RUN: llvm-profdata merge %S/Inputs/cxx-templates.proftext -o %t.profdata
|
2016-03-03 04:59:36 +08:00
|
|
|
// 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
|
2014-04-12 08:54:06 +08:00
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=T0USE -check-prefix=ALL %s
|
|
|
|
// RUN: FileCheck --input-file=%tuse -check-prefix=T100USE -check-prefix=ALL %s
|
|
|
|
|
[InstrProf] Use separate comdat group for data and counters
Summary:
I hadn't realized that instrumentation runs before inlining, so we can't
use the function as the comdat group. Doing so can create relocations
against discarded sections when references to discarded __profc_
variables are inlined into functions outside the function's comdat
group.
In the future, perhaps we should consider standardizing the comdat group
names that ELF and COFF use. It will save object file size, since
__profv_$sym won't appear in the symbol table again.
Reviewers: xur, vsk
Subscribers: eraman, hiraditya, cfe-commits, #sanitizers, llvm-commits
Tags: #clang, #sanitizers, #llvm
Differential Revision: https://reviews.llvm.org/D58737
llvm-svn: 355044
2019-02-28 07:38:44 +08:00
|
|
|
// T0GEN: @[[T0C:__profc__Z4loopILj0EEvv]] = linkonce_odr {{(hidden|dso_local)}} global [2 x i64] zeroinitializer
|
|
|
|
// T100GEN: @[[T100C:__profc__Z4loopILj100EEvv]] = linkonce_odr {{(hidden|dso_local)}} global [2 x i64] zeroinitializer
|
2014-04-12 08:54:06 +08:00
|
|
|
|
2015-06-30 01:29:50 +08:00
|
|
|
// 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()
|
2014-04-12 08:54:06 +08:00
|
|
|
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
|
|
|
|
}
|
|
|
|
|
2020-10-01 03:11:46 +08:00
|
|
|
// T0USE-DAG: ![[T01]] = !{!"branch_weights", i64 1, i64 2}
|
|
|
|
// T100USE-DAG: ![[T1001]] = !{!"branch_weights", i64 101, i64 2}
|
2014-04-12 08:54:06 +08:00
|
|
|
|
|
|
|
int main(int argc, const char *argv[]) {
|
|
|
|
loop<0>();
|
|
|
|
loop<100>();
|
|
|
|
return 0;
|
|
|
|
}
|