1// Test that we can have a statement that throws in hot cold
2// and a landing pad in cold code.
3//
4// Record performance data with no args. Run test with 2 args.
5
6#include <stdint.h>
7#include <stdio.h>
8
9int foo() { return 0; }
10
11void bar(int a) {
12 if (a > 2 && a % 2)
13 throw new int();
14}
15
16void filter_only() { foo(); }
17
18int main(int argc, char **argv) {
19 unsigned r = 0;
20
21 uint64_t limit = (argc >= 2 ? 10 : 5000);
22 for (uint64_t i = 0; i < limit; ++i) {
23 i += foo();
24 try {
25 bar(a: argc);
26 try {
27 if (argc >= 2)
28 throw new int();
29 } catch (...) {
30 printf(format: "catch 2\n");
31 throw new int();
32 }
33 } catch (...) {
34 printf(format: "catch 1\n");
35 }
36 }
37
38 return 0;
39}
40

source code of bolt/test/runtime/Inputs/exceptions_split.cpp