58 lines · cpp
1// Make sure that we're aligning the stack properly to support handlers that2// expect 16-byte alignment of the stack.3//4// RUN: %clangxx_xray -std=c++11 %s -o %t5// RUN: env XRAY_OPTIONS="patch_premain=false verbosity=1" \6// RUN: %run %t 2>&17// REQUIRES: x86_64-target-arch8// REQUIRES: built-in-llvm-tree9#include "xray/xray_interface.h"10#include <stdio.h>11#include <xmmintrin.h>12 13[[clang::xray_never_instrument]] __attribute__((weak)) __m128 f(__m128 *i) {14 return *i;15}16 17[[clang::xray_always_instrument]] __attribute__((noinline)) void noarg() {18 __m128 v = {};19 f(&v);20}21 22[[ clang::xray_always_instrument, clang::xray_log_args(1) ]]23__attribute__((noinline)) void arg1(int) {24 __m128 v = {};25 f(&v);26}27 28[[clang::xray_always_instrument]] __attribute__((noinline))29void no_alignment() {}30 31[[clang::xray_never_instrument]] void noarg_handler(int32_t,32 XRayEntryType) {33 printf("noarg handler called\n");34 __m128 v = {};35 f(&v);36}37 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);43}44 45int 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 called50 arg1(argc); // CHECK: arg1 handler called51 no_alignment();52 __xray_unpatch();53 __xray_remove_handler();54 __xray_remove_handler_arg1();55 noarg();56 arg1(argc);57}58