43 lines · cpp
1// Make sure we're aligning the stack properly when lowering the custom event2// calls.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 <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(&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("handler called\n");29 __m128 v = {};30 f(&v);31}32 33int main(int argc, char* argv[]) {34 __xray_set_customevent_handler(printer);35 __xray_patch();36 foo(); // CHECK: handler called37 bar(); // CHECK: handler called38 __xray_unpatch();39 __xray_remove_customevent_handler();40 foo();41 bar();42}43