summaryrefslogtreecommitdiffstats
path: root/clang/test/Profile/cxx-class.cpp
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2014-03-11 04:37:49 +0000
committerJustin Bogner <mail@justinbogner.com>2014-03-11 04:37:49 +0000
commit52a6a97d70c2c39ee498ee4802b5130446e5595e (patch)
tree4189684b546c5a482d0e5e9a62288f153c72685b /clang/test/Profile/cxx-class.cpp
parenta4fb799d000506ed2e0edd3e01f1de12cc66e826 (diff)
downloadbcm5719-llvm-52a6a97d70c2c39ee498ee4802b5130446e5595e.tar.gz
bcm5719-llvm-52a6a97d70c2c39ee498ee4802b5130446e5595e.zip
test: Give instrumentation based profiling tests their own directory
These tests are logically related, but they're spread about several different CodeGen directories. Consolidate them in one place to make them easier to manage. llvm-svn: 203541
Diffstat (limited to 'clang/test/Profile/cxx-class.cpp')
-rw-r--r--clang/test/Profile/cxx-class.cpp77
1 files changed, 77 insertions, 0 deletions
diff --git a/clang/test/Profile/cxx-class.cpp b/clang/test/Profile/cxx-class.cpp
new file mode 100644
index 00000000000..5934a0adb7d
--- /dev/null
+++ b/clang/test/Profile/cxx-class.cpp
@@ -0,0 +1,77 @@
+// Tests for instrumentation of C++ methods, constructors, and destructors.
+
+// RUN: %clang %s -o - -emit-llvm -S -fprofile-instr-generate -fno-exceptions -target %itanium_abi_triple > %tgen
+// RUN: FileCheck --input-file=%tgen -check-prefix=CTRGEN %s
+// 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: %clang %s -o - -emit-llvm -S -fprofile-instr-use=%S/Inputs/cxx-class.profdata -fno-exceptions -target %itanium_abi_triple > %tuse
+// RUN: FileCheck --input-file=%tuse -check-prefix=CTRUSE %s
+// 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
+
+class Simple {
+ int Member;
+public:
+ // CTRGEN-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
+ // CTRUSE-LABEL: define {{.*}} @_ZN6SimpleC2Ei(
+ // CTRGEN: store {{.*}} @[[SCC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0
+ explicit Simple(int Member) : Member(Member) {
+ // CTRGEN: store {{.*}} @[[SCC]], i64 0, i64 1
+ // CTRUSE: br {{.*}} !prof ![[SC1:[0-9]+]]
+ if (Member) {}
+ // CTRGEN-NOT: store {{.*}} @[[SCC]],
+ // CTRUSE-NOT: br {{.*}} !prof ![0-9]+
+ // CTRUSE: ret
+ }
+ // CTRUSE: ![[SC1]] = metadata !{metadata !"branch_weights", i32 100, i32 2}
+
+ // DTRGEN-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
+ // DTRUSE-LABEL: define {{.*}} @_ZN6SimpleD2Ev(
+ // DTRGEN: store {{.*}} @[[SDC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0
+ ~Simple() {
+ // DTRGEN: store {{.*}} @[[SDC]], i64 0, i64 1
+ // DTRUSE: br {{.*}} !prof ![[SD1:[0-9]+]]
+ if (Member) {}
+ // DTRGEN-NOT: store {{.*}} @[[SDC]],
+ // DTRUSE-NOT: br {{.*}} !prof ![0-9]+
+ // DTRUSE: ret
+ }
+ // DTRUSE: ![[SD1]] = metadata !{metadata !"branch_weights", i32 100, i32 2}
+
+ // MTHGEN-LABEL: define {{.*}} @_ZN6Simple6methodEv(
+ // MTHUSE-LABEL: define {{.*}} @_ZN6Simple6methodEv(
+ // MTHGEN: store {{.*}} @[[SMC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0
+ void method() {
+ // MTHGEN: store {{.*}} @[[SMC]], i64 0, i64 1
+ // MTHUSE: br {{.*}} !prof ![[SM1:[0-9]+]]
+ if (Member) {}
+ // MTHGEN-NOT: store {{.*}} @[[SMC]],
+ // MTHUSE-NOT: br {{.*}} !prof ![0-9]+
+ // MTHUSE: ret
+ }
+ // MTHUSE: ![[SM1]] = metadata !{metadata !"branch_weights", i32 100, i32 2}
+};
+
+// WRPGEN-LABEL: define {{.*}} @_Z14simple_wrapperv(
+// WRPUSE-LABEL: define {{.*}} @_Z14simple_wrapperv(
+// WRPGEN: store {{.*}} @[[SWC:__llvm_pgo_ctr[0-9]*]], i64 0, i64 0
+void simple_wrapper() {
+ // WRPGEN: store {{.*}} @[[SWC]], i64 0, i64 1
+ // WRPUSE: br {{.*}} !prof ![[SW1:[0-9]+]]
+ for (int I = 0; I < 100; ++I) {
+ Simple S(I);
+ S.method();
+ }
+ // WRPGEN-NOT: store {{.*}} @[[SWC]],
+ // WRPUSE-NOT: br {{.*}} !prof ![0-9]+
+ // WRPUSE: ret
+}
+// WRPUSE: ![[SW1]] = metadata !{metadata !"branch_weights", i32 100, i32 2}
+
+int main(int argc, const char *argv[]) {
+ simple_wrapper();
+ return 0;
+}
OpenPOWER on IntegriCloud