1// Make sure we're aligning the stack properly when lowering the custom event
2// calls.
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 <xmmintrin.h>
10#include <stdio.h>
11#include "xray/xray_interface.h"
12
13[[clang::xray_never_instrument]] __attribute__((weak)) __m128 f(__m128 *i) {
14 return *i;
15}
16
17[[clang::xray_always_instrument]] void foo() {
18 __xray_customevent(0, 0);
19 __m128 v = {};
20 f(i: &v);
21}
22
23[[clang::xray_always_instrument]] void bar() {
24 __xray_customevent(0, 0);
25}
26
27void printer(void* ptr, size_t size) {
28 printf(format: "handler called\n");
29 __m128 v = {};
30 f(i: &v);
31}
32
33int main(int argc, char* argv[]) {
34 __xray_set_customevent_handler(entry: printer);
35 __xray_patch();
36 foo(); // CHECK: handler called
37 bar(); // CHECK: handler called
38 __xray_unpatch();
39 __xray_remove_customevent_handler();
40 foo();
41 bar();
42}
43

source code of compiler-rt/test/xray/TestCases/Posix/custom-event-handler-alignment.cpp