xref: /llvm-project/bolt/test/runtime/pie-exceptions-split.test (revision 777e268b8168b326db54ecacb62733ee926bb781)
1## Check that BOLT successfully splits C++ exception-handling code for
2## PIEs or shared objects.
3
4REQUIRES: system-linux,bolt-runtime
5
6RUN: %clangxx %cxxflags -pie -fPIC %p/Inputs/exceptions_split.cpp -Wl,-q -o %t
7RUN: llvm-bolt %t -o %t.instr --instrument --instrumentation-file=%t.fdata
8
9## Record profile with invocation that does not throw exceptions.
10RUN: %t.instr
11
12RUN: llvm-bolt %t -o %t.bolt --data %t.fdata --reorder-blocks=ext-tsp \
13RUN:   --split-functions --split-eh --print-after-lowering \
14RUN:   --print-only=main 2>&1 | FileCheck %s
15
16## All calls to printf() should be from exception handling code that was
17## recorded as cold during the profile collection run. Check that the calls
18## are placed after the split point.
19CHECK-NOT: printf
20CHECK: HOT-COLD SPLIT POINT
21CHECK:     printf
22
23## Verify the output still executes correctly when the exception path is being
24## taken.
25RUN: %t.bolt arg1 arg2 arg3 2>&1 | FileCheck --check-prefix=CHECK-BOLTED %s
26
27CHECK-BOLTED:      catch 2
28CHECK-BOLTED-NEXT: catch 1
29