Files
clang-p2996/bolt/test/runtime/X86/Inputs/exceptions_split.cpp
Maksim Panchenko f263a66ba0 [BOLT] Split functions with exceptions in shared objects and PIEs
Add functionality to allow splitting code with C++ exceptions in shared
libraries and PIEs. To overcome a limitation in exception ranges format,
for functions with fragments spanning multiple sections, add trampoline
landing pads in the same section as the corresponding throwing range.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D127936
2022-06-19 16:48:48 -07:00

46 lines
726 B
C++

// Test that we can have a statement that throws in hot cold
// and a landing pad in cold code.
//
// Record performance data with no args. Run test with 2 args.
#include <stdio.h>
#include <stdint.h>
int foo()
{
return 0;
}
void bar(int a) {
if (a > 2 && a % 2)
throw new int();
}
void filter_only(){
foo();
}
int main(int argc, char **argv)
{
unsigned r = 0;
uint64_t limit = (argc >= 2 ? 10 : 5000);
for (uint64_t i = 0; i < limit; ++i) {
i += foo();
try {
bar(argc);
try {
if (argc >= 2)
throw new int();
} catch (...) {
printf("catch 2\n");
throw new int();
}
} catch (...) {
printf("catch 1\n");
}
}
return 0;
}