diff options
Diffstat (limited to 'test/profile/Inputs')
-rw-r--r-- | test/profile/Inputs/comdat_rename.h | 13 | ||||
-rw-r--r-- | test/profile/Inputs/comdat_rename_1.cc | 33 | ||||
-rw-r--r-- | test/profile/Inputs/comdat_rename_2.cc | 18 | ||||
-rw-r--r-- | test/profile/Inputs/extern_template.h | 10 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-comdat.h | 16 | ||||
-rw-r--r-- | test/profile/Inputs/instrprof-dynamic-a.cpp | 10 |
6 files changed, 82 insertions, 18 deletions
diff --git a/test/profile/Inputs/comdat_rename.h b/test/profile/Inputs/comdat_rename.h new file mode 100644 index 0000000000000..d30628f13b63c --- /dev/null +++ b/test/profile/Inputs/comdat_rename.h @@ -0,0 +1,13 @@ +struct FOO { + FOO() : a(0), b(0) {} + int callee(); + __attribute__((noinline)) void caller(int n) { + int r = callee(); + if (r == 0) { + a += n; + b += 1; + } + } + int a; + int volatile b; +}; diff --git a/test/profile/Inputs/comdat_rename_1.cc b/test/profile/Inputs/comdat_rename_1.cc new file mode 100644 index 0000000000000..688e305310c52 --- /dev/null +++ b/test/profile/Inputs/comdat_rename_1.cc @@ -0,0 +1,33 @@ +#include "comdat_rename.h" +// callee's out-of-line instance profile data -- it comes +// from external calls to it from comdat_rename_2.cc. +// Its inline instance copy's profile data is different and +// is collected in 'caller''s context. +int FOO::callee() { + // CHECK-LABEL: define {{.*}}callee{{.*}} + // CHECK-NOT: br i1 {{.*}} + // CHECK: br {{.*}}label{{.*}}, label %[[BB1:.*]], !prof ![[PD1:[0-9]+]] + // CHECK: {{.*}}[[BB1]]: + if (b != 0) + return a / b; + if (a != 0) + return 10 / a; + return 0; +} + +// This is the 'caller''s comdat copy (after renaming) in this module. +// The profile counters include a copy of counters from 'callee': +// +// CHECK-LABEL: define {{.*}}caller{{.*}} +// CHECK-NOT: br i1 {{.*}} +// CHECK: br {{.*}}label{{.*}}, label %[[BB2:.*]], !prof ![[PD2:[0-9]+]] +// CHECK: {{.*}}[[BB2]]: +// CHECK: br {{.*}}label{{.*}}, label %{{.*}}, !prof !{{.*}} +// CHECK: br {{.*}}label %[[BB3:.*]], label %{{.*}} !prof ![[PD3:[0-9]+]] +// CHECK: {{.*}}[[BB3]]: +// +// CHECK:![[PD1]] = !{!"branch_weights", i32 0, i32 1} +// CHECK:![[PD2]] = !{!"branch_weights", i32 1, i32 0} +// CHECK:![[PD3]] = !{!"branch_weights", i32 {{.*}}, i32 0} + +void test(FOO *foo) { foo->caller(10); } diff --git a/test/profile/Inputs/comdat_rename_2.cc b/test/profile/Inputs/comdat_rename_2.cc new file mode 100644 index 0000000000000..5cad79c9f9d8b --- /dev/null +++ b/test/profile/Inputs/comdat_rename_2.cc @@ -0,0 +1,18 @@ +#include "comdat_rename.h" +extern void test(FOO *); +FOO foo; +int main() { + test(&foo); + foo.caller(20); + return 0; +} + +// The copy of 'caller' defined in this module -- it has +// 'callee' call remaining. +// +// CHECK-LABEL: define {{.*}}caller{{.*}} +// CHECK: {{.*}} call {{.*}} +// CHECK-NOT: br i1 {{.*}} +// CHECK: br {{.*}}label %[[BB1:.*]], label{{.*}}!prof ![[PD1:[0-9]+]] +// CHECK: {{.*}}[[BB1]]: +// CHECK:![[PD1]] = !{!"branch_weights", i32 0, i32 1} diff --git a/test/profile/Inputs/extern_template.h b/test/profile/Inputs/extern_template.h index 01c1d1abfff54..aa59f6c1e6006 100644 --- a/test/profile/Inputs/extern_template.h +++ b/test/profile/Inputs/extern_template.h @@ -1,10 +1,10 @@ template <typename T> struct Test { Test() : M(10) {} - void doIt(int N) { // CHECK: 2| [[@LINE]]| void doIt - if (N > 10) { // CHECK: 2| [[@LINE]]| if (N > 10) { - M += 2; // CHECK: 1| [[@LINE]]| M += 2; - } else // CHECK: 1| [[@LINE]]| } else - M -= 2; // CHECK: 1| [[@LINE]]| M -= 2; + void doIt(int N) { // CHECK: [[@LINE]]| 2| void doIt + if (N > 10) { // CHECK: [[@LINE]]| 2| if (N > 10) { + M += 2; // CHECK: [[@LINE]]| 1| M += 2; + } else // CHECK: [[@LINE]]| 1| } else + M -= 2; // CHECK: [[@LINE]]| 1| M -= 2; } T M; }; diff --git a/test/profile/Inputs/instrprof-comdat.h b/test/profile/Inputs/instrprof-comdat.h index db1a5ba63e589..61e283cc878ed 100644 --- a/test/profile/Inputs/instrprof-comdat.h +++ b/test/profile/Inputs/instrprof-comdat.h @@ -12,12 +12,12 @@ private: T t; }; -template <class T> T FOO<T>::DoIt(T ti) { // HEADER: 2| [[@LINE]]|template - for (T I = 0; I < ti; I++) { // HEADER: 22| [[@LINE]]| for (T - t += I; // HEADER: 20| [[@LINE]]| t += I; - if (I > ti / 2) // HEADER: 20| [[@LINE]]| if (I > ti - t -= 1; // HEADER: 8| [[@LINE]]| t -= 1; - } // HEADER: 10| [[@LINE]]| } - // HEADER: 1| [[@LINE]]| - return t; // HEADER: 1| [[@LINE]]| return t; +template <class T> T FOO<T>::DoIt(T ti) { // HEADER: [[@LINE]]| 2|template + for (T I = 0; I < ti; I++) { // HEADER: [[@LINE]]| 22| for (T + t += I; // HEADER: [[@LINE]]| 20| t += I; + if (I > ti / 2) // HEADER: [[@LINE]]| 20| if (I > ti + t -= 1; // HEADER: [[@LINE]]| 8| t -= 1; + } // HEADER: [[@LINE]]| 10| } + // HEADER: [[@LINE]]| 1| + return t; // HEADER: [[@LINE]]| 1| return t; } diff --git a/test/profile/Inputs/instrprof-dynamic-a.cpp b/test/profile/Inputs/instrprof-dynamic-a.cpp index 5faa9c2b2a80f..7468cd4eb04ef 100644 --- a/test/profile/Inputs/instrprof-dynamic-a.cpp +++ b/test/profile/Inputs/instrprof-dynamic-a.cpp @@ -1,7 +1,7 @@ #include "instrprof-dynamic-header.h" -void a() { // COV: 1| [[@LINE]]|void a - if (true) { // COV: 1| [[@LINE]]| if - bar<void>(1); // COV: 1| [[@LINE]]| bar - bar<char>(1); // COV: 1| [[@LINE]]| bar - } // COV: 1| [[@LINE]]| } +void a() { // COV: [[@LINE]]| 1|void a + if (true) { // COV: [[@LINE]]| 1| if + bar<void>(1); // COV: [[@LINE]]| 1| bar + bar<char>(1); // COV: [[@LINE]]| 1| bar + } // COV: [[@LINE]]| 1| } } |