# Check instrumentation of C++ code with exceptions

REQUIRES: system-linux

RUN: %clangxx %cxxflags -no-pie %p/Inputs/exceptions_split.cpp -Wl,-q -g -o %t_exc_split
RUN: llvm-bolt %t_exc_split -o %t.exc -instrument -instrumentation-file=%t.fdata

RUN: %t.exc arg1 arg2 arg3

RUN: llvm-bolt %t_exc_split -o %t.exc.bolted -data %t.fdata \
RUN:   -reorder-blocks=cache+ -reorder-functions=hfsort+ -split-functions=3 \
RUN:   -split-eh=1 | FileCheck --check-prefix=EXCEPTIONS %s
EXCEPTIONS-NOT: invalid (possibly stale) profile

# Check that cold symbols are emitted with local binding.
RUN: llvm-readelf -Ws %t.exc.bolted | FileCheck %s --check-prefix=CHECK-READELF
CHECK-READELF: FUNC    LOCAL  DEFAULT   {{.*}} main.cold.{{.*}}

RUN: cat %t.fdata | FileCheck --check-prefix=EXCEPTIONS-FDATA %s
# Check that the printf "catch" ran exactly 10 times
EXCEPTIONS-FDATA: 1 main {{.*}} 1 _Znwm@PLT 0 0 10
