summaryrefslogtreecommitdiff
path: root/test/Profile
diff options
context:
space:
mode:
authorBetul Buyukkurt <betulb@codeaurora.org>2016-03-29 20:44:09 +0000
committerBetul Buyukkurt <betulb@codeaurora.org>2016-03-29 20:44:09 +0000
commita393dca7ea5cdd5de3a8c4cb20c83d050df39793 (patch)
tree7e5694ab046b06bdcd916a9a348ec2f9659b3297 /test/Profile
parent4e812c1ad7fd5c49300c5ed2b8903c68cb9281b5 (diff)
downloadclang-a393dca7ea5cdd5de3a8c4cb20c83d050df39793.tar.gz
[PGO] Move the instrumentation point closer to the value site.
For terminator instructions, the value profiling instrumentation happens in a basic block other than where the value site resides. This CR moves the instrumentation point prior to the value site. Mostly NFC. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@264783 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Profile')
-rw-r--r--test/Profile/c-indirect-call.c5
-rw-r--r--test/Profile/cxx-indirect-call.cpp21
2 files changed, 24 insertions, 2 deletions
diff --git a/test/Profile/c-indirect-call.c b/test/Profile/c-indirect-call.c
index ab66c58954..b0ace37267 100644
--- a/test/Profile/c-indirect-call.c
+++ b/test/Profile/c-indirect-call.c
@@ -1,13 +1,14 @@
-// Check the data structures emitted by instrumentation.
+// Check the value profiling instrinsics emitted by instrumentation.
+
// RUN: %clang_cc1 -triple x86_64-apple-macosx10.9 -main-file-name c-indirect-call.c %s -o - -emit-llvm -fprofile-instrument=clang -mllvm -enable-value-profiling | FileCheck %s
void (*foo)(void);
int main(void) {
// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 8
-// CHECK-NEXT: call void [[REG1]]()
// CHECK-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
// CHECK-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT: call void [[REG1]]()
foo();
return 0;
}
diff --git a/test/Profile/cxx-indirect-call.cpp b/test/Profile/cxx-indirect-call.cpp
new file mode 100644
index 0000000000..15dc79cece
--- /dev/null
+++ b/test/Profile/cxx-indirect-call.cpp
@@ -0,0 +1,21 @@
+// Check the value profiling instrinsics emitted by instrumentation.
+
+// RUN: %clangxx %s -o - -emit-llvm -S -fprofile-instr-generate -mllvm -enable-value-profiling -fexceptions -target %itanium_abi_triple | FileCheck %s
+
+void (*foo) (void);
+
+int main(int argc, const char *argv[]) {
+// CHECK: [[REG1:%[0-9]+]] = load void ()*, void ()** @foo, align 4
+// CHECK-NEXT: [[REG2:%[0-9]+]] = ptrtoint void ()* [[REG1]] to i64
+// CHECK-NEXT: call void @__llvm_profile_instrument_target(i64 [[REG2]], i8* bitcast ({{.*}}* @__profd_main to i8*), i32 0)
+// CHECK-NEXT: invoke void [[REG1]]()
+ try {
+ foo();
+ } catch (int) {}
+ return 0;
+}
+
+// CHECK: declare void @__llvm_profile_instrument_target(i64, i8*, i32)
+
+
+