Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / xray / TestCases / Posix / pic_test.cpp
blobfbf6bdcd4a7d76099546f05f6f0c2f4a8fc8387c
1 // Test to check if we handle pic code properly.
3 // RUN: %clangxx_xray -fxray-instrument -std=c++11 -ffunction-sections \
4 // RUN: -fdata-sections -fpic -fpie -Wl,--gc-sections %s -o %t
5 // RUN: rm -f pic-test-logging-*
6 // RUN: XRAY_OPTIONS="patch_premain=true verbosity=1 xray_mode=xray-basic \
7 // RUN: xray_logfile_base=pic-test-logging-" %run %t 2>&1 | FileCheck %s
8 // After all that, clean up the output xray log.
9 //
10 // RUN: rm -f pic-test-logging-*
12 // UNSUPPORTED: target-is-mips64,target-is-mips64el
14 #include <cstdio>
16 [[clang::xray_always_instrument]]
17 unsigned short foo (unsigned b);
19 [[clang::xray_always_instrument]]
20 unsigned short bar (unsigned short a)
22 printf("bar() is always instrumented!\n");
23 return foo(a);
26 unsigned short foo (unsigned b)
28 printf("foo() is always instrumented!\n");
29 return b + b + 5;
32 int main ()
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!