Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / CodeGenCXX / exceptions-cxx-new.cpp
blobacf0f27cb199dbda257b4dd972cf4741c4168f1a
1 // RUN: %clang_cc1 %s -triple i686-pc-win32 -fms-extensions -fexceptions -fcxx-exceptions -emit-llvm -o - -std=c++11 | FileCheck %s
3 int f(int);
5 void test_catch() {
6 try {
7 f(1);
8 } catch (int) {
9 f(2);
10 } catch (double) {
11 f(3);
15 // CHECK-LABEL: define dso_local void @"?test_catch@@YAXXZ"(
16 // CHECK: invoke noundef i32 @"?f@@YAHH@Z"(i32 noundef 1)
17 // CHECK: to label %[[NORMAL:.*]] unwind label %[[CATCHSWITCH:.*]]
19 // CHECK: [[CATCHSWITCH]]
20 // CHECK: %[[CATCHSWITCHPAD:.*]] = catchswitch within none [label %[[CATCH_INT:.*]], label %[[CATCH_DOUBLE:.*]]] unwind to caller
22 // CHECK: [[CATCH_INT]]
23 // CHECK: %[[CATCHPAD_INT:.*]] = catchpad within %[[CATCHSWITCHPAD]] [ptr @"??_R0H@8", i32 0, ptr null]
24 // CHECK: call noundef i32 @"?f@@YAHH@Z"(i32 noundef 2)
25 // CHECK: catchret from %[[CATCHPAD_INT]] to label %[[LEAVE_INT_CATCH:.*]]
27 // CHECK: [[LEAVE_INT_CATCH]]
28 // CHECK: br label %[[LEAVE_FUNC:.*]]
30 // CHECK: [[LEAVE_FUNC]]
31 // CHECK: ret void
33 // CHECK: [[CATCH_DOUBLE]]
34 // CHECK: %[[CATCHPAD_DOUBLE:.*]] = catchpad within %[[CATCHSWITCHPAD]] [ptr @"??_R0N@8", i32 0, ptr null]
35 // CHECK: call noundef i32 @"?f@@YAHH@Z"(i32 noundef 3)
36 // CHECK: catchret from %[[CATCHPAD_DOUBLE]] to label %[[LEAVE_DOUBLE_CATCH:.*]]
38 // CHECK: [[LEAVE_DOUBLE_CATCH]]
39 // CHECK: br label %[[LEAVE_FUNC]]
41 // CHECK: [[NORMAL]]
42 // CHECK: br label %[[LEAVE_FUNC]]
44 struct Cleanup {
45 ~Cleanup() { f(-1); }
48 void test_cleanup() {
49 Cleanup C;
50 f(1);
53 // CHECK-LABEL: define dso_local {{.*}} @"?test_cleanup@@YAXXZ"(
54 // CHECK: invoke noundef i32 @"?f@@YAHH@Z"(i32 noundef 1)
55 // CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[CLEANUP:.*]]
57 // CHECK: [[LEAVE_FUNC]]
58 // CHECK: call x86_thiscallcc void @"??1Cleanup@@QAE@XZ"(
59 // CHECK: ret void
61 // CHECK: [[CLEANUP]]
62 // CHECK: %[[CLEANUPPAD:.*]] = cleanuppad within none []
63 // CHECK: call x86_thiscallcc void @"??1Cleanup@@QAE@XZ"(
64 // CHECK: cleanupret from %[[CLEANUPPAD]] unwind to caller
67 // CHECK-LABEL: define {{.*}} void @"??1Cleanup@@QAE@XZ"(
68 // CHECK: invoke noundef i32 @"?f@@YAHH@Z"(i32 noundef -1)
69 // CHECK: to label %[[LEAVE_FUNC:.*]] unwind label %[[TERMINATE:.*]]
71 // CHECK: [[LEAVE_FUNC]]
72 // CHECK: ret void
74 // CHECK: [[TERMINATE]]
75 // CHECK: %[[CLEANUPPAD:.*]] = cleanuppad within none []
76 // CHECK-NEXT: call void @"?terminate@@YAXXZ"() {{.*}} [ "funclet"(token %[[CLEANUPPAD]]) ]