Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / xray / TestCases / Posix / common-trampoline-alignment.cpp
blobf9189644b40b8e61fdcc81126730dce17b835287
1 // Make sure that we're aligning the stack properly to support handlers that
2 // expect 16-byte alignment of the stack.
3 //
4 // RUN: %clangxx_xray -std=c++11 %s -o %t
5 // RUN: XRAY_OPTIONS="patch_premain=false verbosity=1" \
6 // RUN: %run %t 2>&1
7 // REQUIRES: x86_64-target-arch
8 // REQUIRES: built-in-llvm-tree
9 #include "xray/xray_interface.h"
10 #include <stdio.h>
11 #include <xmmintrin.h>
13 [[clang::xray_never_instrument]] __attribute__((weak)) __m128 f(__m128 *i) {
14 return *i;
17 [[clang::xray_always_instrument]] __attribute__((noinline)) void noarg() {
18 __m128 v = {};
19 f(&v);
22 [[ clang::xray_always_instrument, clang::xray_log_args(1) ]]
23 __attribute__((noinline)) void arg1(int) {
24 __m128 v = {};
25 f(&v);
28 [[clang::xray_always_instrument]] __attribute__((noinline))
29 void no_alignment() {}
31 [[clang::xray_never_instrument]] void noarg_handler(int32_t,
32 XRayEntryType) {
33 printf("noarg handler called\n");
34 __m128 v = {};
35 f(&v);
38 [[clang::xray_never_instrument]] void arg1_handler(int32_t, XRayEntryType,
39 uint64_t) {
40 printf("arg1 handler called\n");
41 __m128 v = {};
42 f(&v);
45 int main(int argc, char *argv[]) {
46 __xray_set_handler(noarg_handler);
47 __xray_set_handler_arg1(arg1_handler);
48 __xray_patch();
49 noarg(); // CHECK: noarg handler called
50 arg1(argc); // CHECK: arg1 handler called
51 no_alignment();
52 __xray_unpatch();
53 __xray_remove_handler();
54 __xray_remove_handler_arg1();
55 noarg();
56 arg1(argc);