llvm-project/bolt/test/runtime/X86/Inputs/exceptions_split.cpp
Amir Ayupov 2d97f0f2ef [BOLT][TEST] Move exceptions-instrumentation.test to X86
The aarch64 instrumentation is currently unsupported so the test is failing.

Reviewed By: Amir

Differential Revision: https://reviews.llvm.org/D117102
2022-01-12 09:25:12 -08:00

46 lines
731 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 : 500000000);
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;
}