diff options
author | Kamil Rytarowski <n54@gmx.com> | 2018-02-22 06:08:26 +0000 |
---|---|---|
committer | Kamil Rytarowski <n54@gmx.com> | 2018-02-22 06:08:26 +0000 |
commit | 9665582c0a1e0e2528e3eeb0fa1cfdfd4be26e63 (patch) | |
tree | 0dbef83d069c28d1dd420bc1e829c3cd718b8640 /test/xray/TestCases/Posix/common-trampoline-alignment.cc | |
parent | deef7d3300634a52fcd6aadb3b2fd88491ea959e (diff) |
Xray instrumentation / enabling more tests
Summary:
The Unix subdirectory mostly allows only on Linux x86_64 but now we can target x86_64 arch in general.
Patch by David CARLIER
Reviewers: krytarowski, dberris, emaste
Reviewed By: krytarowski, dberris, emaste
Subscribers: emaste, llvm-commits, #sanitizers
Differential Revision: https://reviews.llvm.org/D43382
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@325743 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/xray/TestCases/Posix/common-trampoline-alignment.cc')
-rw-r--r-- | test/xray/TestCases/Posix/common-trampoline-alignment.cc | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/test/xray/TestCases/Posix/common-trampoline-alignment.cc b/test/xray/TestCases/Posix/common-trampoline-alignment.cc new file mode 100644 index 000000000..dac0789ab --- /dev/null +++ b/test/xray/TestCases/Posix/common-trampoline-alignment.cc @@ -0,0 +1,57 @@ +// Make sure that we're aligning the stack properly to support handlers that +// expect 16-byte alignment of the stack. +// +// RUN: %clangxx_xray -std=c++11 %s -o %t +// RUN: XRAY_OPTIONS="patch_premain=false verbosity=1 xray_naive_log=false" \ +// RUN: %run %t 2>&1 +// REQUIRES: x86_64-target-arch +// REQUIRES: built-in-llvm-tree +#include "xray/xray_interface.h" +#include <stdio.h> +#include <xmmintrin.h> + +[[clang::xray_never_instrument]] __attribute__((weak)) __m128 f(__m128 *i) { + return *i; +} + +[[clang::xray_always_instrument]] __attribute__((noinline)) void noarg() { + __m128 v = {}; + f(&v); +} + +[[ clang::xray_always_instrument, clang::xray_log_args(1) ]] +__attribute__((noinline)) void arg1(int) { + __m128 v = {}; + f(&v); +} + +[[clang::xray_always_instrument]] __attribute__((noinline)) +void no_alignment() {} + +[[clang::xray_never_instrument]] void noarg_handler(int32_t, + XRayEntryType) { + printf("noarg handler called\n"); + __m128 v = {}; + f(&v); +} + +[[clang::xray_never_instrument]] void arg1_handler(int32_t, XRayEntryType, + uint64_t) { + printf("arg1 handler called\n"); + __m128 v = {}; + f(&v); +} + +int main(int argc, char *argv[]) { + __xray_set_handler(noarg_handler); + __xray_set_handler_arg1(arg1_handler); + __xray_patch(); + noarg(); // CHECK: noarg handler called + arg1(argc); // CHECK: arg1 handler called + no_alignment(); + __xray_unpatch(); + __xray_remove_handler(); + __xray_remove_handler_arg1(); + noarg(); + arg1(argc); +} |