summaryrefslogtreecommitdiff
path: root/test/Profile
diff options
context:
space:
mode:
Diffstat (limited to 'test/Profile')
-rw-r--r--test/Profile/Inputs/cxx-class.proftext11
-rw-r--r--test/Profile/c-generate.c3
-rw-r--r--test/Profile/c-ternary.c15
-rw-r--r--test/Profile/cxx-class.cpp36
-rw-r--r--test/Profile/cxx-structors.cpp39
-rw-r--r--test/Profile/cxx-virtual-destructor-calls.cpp9
6 files changed, 94 insertions, 19 deletions
diff --git a/test/Profile/Inputs/cxx-class.proftext b/test/Profile/Inputs/cxx-class.proftext
index b4645edf93335..77645fbc2066c 100644
--- a/test/Profile/Inputs/cxx-class.proftext
+++ b/test/Profile/Inputs/cxx-class.proftext
@@ -39,3 +39,14 @@ _ZN6SimpleC2Ei
100
99
+_ZN7DerivedC1Ev
+10
+2
+100
+99
+
+_ZN7DerivedD2Ev
+10
+2
+100
+99
diff --git a/test/Profile/c-generate.c b/test/Profile/c-generate.c
index 5e5b22e8c30dc..1e7a739e04e4a 100644
--- a/test/Profile/c-generate.c
+++ b/test/Profile/c-generate.c
@@ -5,7 +5,8 @@
//
// PROF-INSTR-PATH: constant [24 x i8] c"c-generate-test.profraw\00"
//
-// PROF-INSTR-NONE-NOT: @__profn_main
+// PROF-INSTR-NONE-NOT: __llvm_prf
+//
// PROF-INSTR-GARBAGE: invalid PGO instrumentor in argument '-fprofile-instrument=garbage'
int main(void) {
diff --git a/test/Profile/c-ternary.c b/test/Profile/c-ternary.c
new file mode 100644
index 0000000000000..af7922fa26fa0
--- /dev/null
+++ b/test/Profile/c-ternary.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
+
+// PR32019: Clang can lower some ternary operator expressions to select
+// instructions. Make sure we only increment the profile counter for the
+// condition when the condition evaluates to true.
+// CHECK-LABEL: define i32 @f1
+int f1(int x) {
+// CHECK: [[TOBOOL:%.*]] = icmp ne i32 %{{.*}}, 0
+// CHECK-NEXT: [[STEP:%.*]] = zext i1 [[TOBOOL]] to i64
+// CHECK-NEXT: [[COUNTER:%.*]] = load i64, i64* getelementptr inbounds ([2 x i64], [2 x i64]* @__profc_f1, i64 0, i64 1)
+// CHECK-NEXT: add i64 [[COUNTER]], [[STEP]]
+// CHECK: [[COND:%.*]] = select i1 [[TOBOOL]], i32 0, i32 1
+ return x ? 0 : 1;
+// CHECK: ret i32 [[COND]]
+}
diff --git a/test/Profile/cxx-class.cpp b/test/Profile/cxx-class.cpp
index dbc9337785e13..ab90d195cdc6c 100644
--- a/test/Profile/cxx-class.cpp
+++ b/test/Profile/cxx-class.cpp
@@ -5,6 +5,8 @@
// RUN: FileCheck --input-file=%tgen -check-prefix=DTRGEN %s
// RUN: FileCheck --input-file=%tgen -check-prefix=MTHGEN %s
// RUN: FileCheck --input-file=%tgen -check-prefix=WRPGEN %s
+// RUN: FileCheck --input-file=%tgen -check-prefix=VCTRGEN %s
+// RUN: FileCheck --input-file=%tgen -check-prefix=VDTRGEN %s
// RUN: llvm-profdata merge %S/Inputs/cxx-class.proftext -o %t.profdata
// RUN: %clang_cc1 %s -o - -emit-llvm -fprofile-instrument-use-path=%t.profdata -triple %itanium_abi_triple > %tuse
@@ -12,10 +14,12 @@
// RUN: FileCheck --input-file=%tuse -check-prefix=DTRUSE %s
// RUN: FileCheck --input-file=%tuse -check-prefix=MTHUSE %s
// RUN: FileCheck --input-file=%tuse -check-prefix=WRPUSE %s
+// RUN: FileCheck --input-file=%tuse -check-prefix=VCTRUSE %s
+// RUN: FileCheck --input-file=%tuse -check-prefix=VDTRUSE %s
class Simple {
- int Member;
public:
+ int Member;
// CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
// CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
// CTRGEN: store {{.*}} @[[SCC:__profc__ZN6SimpleC2Ei]], i64 0, i64 0
@@ -56,6 +60,35 @@ public:
// MTHUSE: ![[SM1]] = !{!"branch_weights", i32 100, i32 2}
};
+class Derived : virtual public Simple {
+public:
+ // VCTRGEN-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
+ // VCTRUSE-LABEL: define {{.*}} @_ZN7DerivedC1Ev(
+ // VCTRGEN: store {{.*}} @[[SCC:__profc__ZN7DerivedC1Ev]], i64 0, i64 0
+ Derived() : Simple(0) {
+ // VCTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
+ // VCTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
+ if (Member) {}
+ // VCTRGEN-NOT: store {{.*}} @[[SCC]],
+ // VCTRUSE-NOT: br {{.*}} !prof ![0-9]+
+ // VCTRUSE: ret
+ }
+ // VCTRUSE: ![[SC1]] = !{!"branch_weights", i32 100, i32 2}
+
+ // VDTRGEN-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
+ // VDTRUSE-LABEL: define {{.*}} @_ZN7DerivedD2Ev(
+ // VDTRGEN: store {{.*}} @[[SDC:__profc__ZN7DerivedD2Ev]], i64 0, i64 0
+ ~Derived() {
+ // VDTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
+ // VDTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
+ if (Member) {}
+ // VDTRGEN-NOT: store {{.*}} @[[SDC]],
+ // VDTRUSE-NOT: br {{.*}} !prof ![0-9]+
+ // VDTRUSE: ret
+ }
+ // VDTRUSE: ![[SD1]] = !{!"branch_weights", i32 100, i32 2}
+};
+
// WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv(
// WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv(
// WRPGEN: store {{.*}} @[[SWC:__profc__Z14simple_wrapperv]], i64 0, i64 0
@@ -63,6 +96,7 @@ void simple_wrapper() {
// WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1
// WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
for (int I = 0; I < 100; ++I) {
+ Derived d;
Simple S(I);
S.method();
}
diff --git a/test/Profile/cxx-structors.cpp b/test/Profile/cxx-structors.cpp
index 73562d39c973f..8e0fac163d975 100644
--- a/test/Profile/cxx-structors.cpp
+++ b/test/Profile/cxx-structors.cpp
@@ -1,6 +1,8 @@
// Tests for instrumentation of C++ constructors and destructors.
//
-// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o - -emit-llvm -fprofile-instrument=clang | FileCheck %s
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -x c++ %s -o %t -emit-llvm -fprofile-instrument=clang
+// RUN: FileCheck %s -input-file=%t -check-prefix=INSTR
+// RUN: FileCheck %s -input-file=%t -check-prefix=NOINSTR
struct Foo {
Foo() {}
@@ -14,19 +16,40 @@ struct Bar : public Foo {
~Bar();
};
+struct Baz : virtual public Foo {
+ Baz() {}
+ Baz(int x) : Foo(x) {}
+ ~Baz();
+};
+
+struct Quux : public Foo {
+ Quux(const char *y, ...) : Foo(0) {}
+};
+
Foo foo;
Foo foo2(1);
Bar bar;
+Baz baz;
+Baz baz2(1);
+Quux qux("fi", "fo", "fum");
// Profile data for complete constructors and destructors must absent.
-// CHECK-NOT: @__profn__ZN3FooC1Ev
-// CHECK-NOT: @__profn__ZN3FooC1Ei
-// CHECK-NOT: @__profn__ZN3FooD1Ev
-// CHECK-NOT: @__profn__ZN3BarC1Ev
-// CHECK-NOT: @__profn__ZN3BarD1Ev
-// CHECK-NOT: @__profc__ZN3FooD1Ev
-// CHECK-NOT: @__profd__ZN3FooD1Ev
+// INSTR: @__profc__ZN3BazC1Ev =
+// INSTR: @__profc__ZN3BazC1Ei =
+// INSTR: @__profc__ZN4QuuxC1EPKcz =
+// INSTR: @__profc_main =
+// INSTR: @__profc__ZN3FooC2Ev =
+// INSTR: @__profc__ZN3FooD2Ev =
+// INSTR: @__profc__ZN3FooC2Ei =
+// INSTR: @__profc__ZN3BarC2Ev =
+
+// NOINSTR-NOT: @__profc__ZN3FooC1Ev
+// NOINSTR-NOT: @__profc__ZN3FooC1Ei
+// NOINSTR-NOT: @__profc__ZN3FooD1Ev
+// NOINSTR-NOT: @__profc__ZN3BarC1Ev
+// NOINSTR-NOT: @__profc__ZN3BarD1Ev
+// NOINSTR-NOT: @__profc__ZN3FooD1Ev
int main() {
}
diff --git a/test/Profile/cxx-virtual-destructor-calls.cpp b/test/Profile/cxx-virtual-destructor-calls.cpp
index cc3df68d3569a..c60fc921e5bfb 100644
--- a/test/Profile/cxx-virtual-destructor-calls.cpp
+++ b/test/Profile/cxx-virtual-destructor-calls.cpp
@@ -13,15 +13,6 @@ struct B : A {
virtual ~B();
};
-// Base dtor
-// CHECK: @__profn__ZN1BD2Ev = private constant [9 x i8] c"_ZN1BD2Ev"
-
-// Complete dtor must not be instrumented
-// CHECK-NOT: @__profn__ZN1BD1Ev = private constant [9 x i8] c"_ZN1BD1Ev"
-
-// Deleting dtor must not be instrumented
-// CHECK-NOT: @__profn__ZN1BD0Ev = private constant [9 x i8] c"_ZN1BD0Ev"
-
// Base dtor counters and profile data
// CHECK: @__profc__ZN1BD2Ev = private global [1 x i64] zeroinitializer
// CHECK: @__profd__ZN1BD2Ev =