1 // RUN: %clang_cc1 -triple x86_64-windows -fasync-exceptions -fcxx-exceptions -fexceptions -fms-extensions -x c++ -Wno-implicit-function-declaration -emit-llvm %s -o - | FileCheck %s
3 // CHECK-LABEL: @main()
4 // CHECK: invoke void @llvm.seh.try.begin()
5 // CHECK: invoke void @llvm.seh.try.begin()
6 // CHECK: %[[src:[0-9-]+]] = load volatile i32, ptr %i
7 // CHECK-NEXT: i32 noundef %[[src]]
8 // CHECK: invoke void @llvm.seh.try.end()
9 // CHECK: invoke void @llvm.seh.try.end()
11 // CHECK: define internal void @"?fin$0@0@main@@"(i8 noundef %abnormal_termination
12 // CHECK: invoke void @llvm.seh.try.begin()
13 // CHECK: invoke void @llvm.seh.try.end()
15 // *****************************************************************************
16 // Abstract: Test __Try in __finally under SEH -EHa option
18 int volatile *NullPtr
= 0;
20 for (int i
= 0; i
< 3; i
++) {
21 printf(" --- Test _Try in _finally --- i = %d \n", i
);
24 printf(" In outer _try i = %d \n", i
);
29 printf(" In outer _finally i = %d \n", i
);
33 printf(" In Inner _finally i = %d \n", i
);
39 printf(" --- In outer except handler i = %d \n", i
);
45 // CHECK-LABEL:@"?foo@@YAXXZ"()
46 // CHECK: invoke.cont:
47 // CHECK: invoke void @llvm.seh.try.begin()
48 // CHECK: store volatile i32 1, ptr %cleanup.dest.slot
49 // CHECK: invoke void @llvm.seh.try.end()
50 // CHECK: invoke.cont2:
51 // CHECK: %cleanup.dest = load i32, ptr %cleanup.dest.slot
52 // CHECK: %1 = icmp ne i32 %cleanup.dest, 0
53 // CHECK: %2 = zext i1 %1 to i8
54 // CHECK: call void @"?fin$0@0@foo@@"(i8 noundef %2, ptr noundef %0)
56 // CHECK: call void @"?fin$0@0@foo@@"(i8 noundef 1, ptr noundef %4)
63 if (_abnormal_termination()) {
71 // CHECK-LABEL:@"?bar@@YAHXZ"()
72 // CHECK: invoke.cont:
73 // CHECK: invoke void @llvm.seh.try.begin()
74 // CHECK: invoke.cont1:
75 // CHECK: store volatile i32 1, ptr %cleanup.dest.slot
76 // CHECK: invoke void @llvm.seh.try.end()
77 // CHECK: invoke.cont2:
78 // CHECK: call void @"?fin$0@0@bar@@"
79 // CHECK: %cleanup.dest3 = load i32, ptr %cleanup.dest.slot
88 if (_abnormal_termination()) {