summaryrefslogtreecommitdiffstats
path: root/compiler-rt/test/xray
diff options
context:
space:
mode:
authorDean Michael Berris <dberris@google.com>2017-04-06 07:14:43 +0000
committerDean Michael Berris <dberris@google.com>2017-04-06 07:14:43 +0000
commit895171e6eea4ffc9d2b25ca4151dfef268bc8148 (patch)
tree21c0641c1736e9f4835c4320dffa2abb59f73c0f /compiler-rt/test/xray
parentfbe67da29b08e7e52e0074989f15b2fa4c3cad98 (diff)
downloadbcm5719-llvm-895171e6eea4ffc9d2b25ca4151dfef268bc8148.tar.gz
bcm5719-llvm-895171e6eea4ffc9d2b25ca4151dfef268bc8148.zip
[XRay] [compiler-rt] Unwriting FDR mode buffers when functions are short.
Summary: "short" is defined as an xray flag, and buffer rewinding happens for both exits and tail exits. I've made the choice to seek backwards finding pairs of FunctionEntry, TailExit record pairs and erasing them if the FunctionEntry occurred before exit from the currently exiting function. This is a compromise so that we don't skip logging tail calls if the function that they call into takes longer our duration. This works by counting the consecutive function and function entry, tail exit pairs that proceed the current point in the buffer. The buffer is rewound to check whether these entry points happened recently enough to be erased. It is still possible we will omit them if they call into a child function that is not instrumented which calls a fast grandchild that is instrumented before doing other processing. Reviewers: pelikan, dberris Reviewed By: dberris Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D31345 llvm-svn: 299629
Diffstat (limited to 'compiler-rt/test/xray')
-rw-r--r--compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc15
1 files changed, 11 insertions, 4 deletions
diff --git a/compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc b/compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc
index 4aa3964c9d1..9fb54ce7b03 100644
--- a/compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc
+++ b/compiler-rt/test/xray/TestCases/Linux/fdr-mode.cc
@@ -1,7 +1,10 @@
// RUN: %clangxx_xray -g -std=c++11 %s -o %t
-// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false xray_logfile_base=fdr-logging-test- xray_fdr_log=true verbosity=1" %run %t 2>&1 | FileCheck %s
-// RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t "`ls fdr-logging-test-* | head -1`" | FileCheck %s --check-prefix TRACE
+// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false xray_logfile_base=fdr-logging-test- xray_fdr_log=true verbosity=1 xray_fdr_log_func_duration_threshold_us=0" %run %t 2>&1 | FileCheck %s
+// RUN: XRAY_OPTIONS="patch_premain=false xray_naive_log=false xray_logfile_base=fdr-unwrite-test- xray_fdr_log=true verbosity=1 xray_fdr_log_func_duration_threshold_us=5000" %run %t 2>&1 | FileCheck %s
+// RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t "`ls fdr-logging-test-* | head -1`" | FileCheck %s --check-prefix=TRACE
+// RUN: %llvm_xray convert --symbolize --output-format=yaml -instr_map=%t "`ls fdr-unwrite-test-* | head -1`" | FileCheck %s --check-prefix=UNWRITE
// RUN: rm fdr-logging-test-*
+// RUN: rm fdr-unwrite-test-*
// FIXME: Make llvm-xray work on non-x86_64 as well.
// REQUIRES: x86_64-linux
@@ -61,8 +64,6 @@ int main(int argc, char *argv[]) {
return 0;
}
-
-
// Check that we're able to see two threads, each entering and exiting fA().
// TRACE-DAG: - { type: 0, func-id: [[FIDA:[0-9]+]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD1:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
// TRACE: - { type: 0, func-id: [[FIDA]], function: {{.*fA.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
@@ -80,3 +81,9 @@ int main(int argc, char *argv[]) {
// TRACE: - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD1]], kind: function-exit, tsc: {{[0-9]+}} }
// TRACE-DAG: - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD2:[0-9]+]], kind: function-enter, tsc: {{[0-9]+}} }
// TRACE: - { type: 0, func-id: [[FIDB]], function: {{.*fB.*}}, cpu: {{.*}}, thread: [[THREAD2]], kind: function-exit, tsc: {{[0-9]+}} }
+
+// Assert that when unwriting is enabled with a high threshold time, all the function records are erased. A CPU switch could erroneously fail this test, but
+// is unlikely given the test program.
+// UNWRITE: header
+// UNWRITE-NOT: function-enter
+// UNWRITE-NOT: function-exit
OpenPOWER on IntegriCloud