brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1019 B · ec1528a Raw
39 lines · cpp
1// Test to check if we handle pic code properly.2 3// RUN: %clangxx_xray -fxray-instrument -std=c++11 -ffunction-sections \4// RUN:     -fdata-sections -fpic -fpie -Wl,--gc-sections %s -o %t5// RUN: rm -f pic-test-logging-*6// RUN: env XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \7// RUN:     xray_logfile_base=pic-test-logging-" %run %t 2>&1 | FileCheck %s8// After all that, clean up the output xray log.9//10// RUN: rm -f pic-test-logging-*11 12// UNSUPPORTED: target-is-mips64,target-is-mips64el13 14#include <cstdio>15 16[[clang::xray_always_instrument]]17unsigned short foo (unsigned b);18 19[[clang::xray_always_instrument]]20unsigned short bar (unsigned short a)21{22  printf("bar() is always instrumented!\n");23  return foo(a);24}25 26unsigned short foo (unsigned b)27{28  printf("foo() is always instrumented!\n");29  return b + b + 5;30}31 32int main ()33{34  // CHECK: XRay: Log file in 'pic-test-logging-{{.*}}'35  bar(10);36  // CHECK: bar() is always instrumented!37  // CHECK-NEXT: foo() is always instrumented!38}39