72 lines · plain
1// RUN: %clang_cc1 -O0 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O02// RUN: %clang_cc1 -O2 -triple x86_64-pc-windows-msvc -emit-llvm -fobjc-arc -fexceptions -fobjc-exceptions -fobjc-arc-exceptions -fobjc-runtime=gnustep-2.0 -o - %s | FileCheck %s --check-prefixes=CHECK,CHECK-O23 4// WinEH requires funclet tokens on nounwind intrinsics if they can lower to5// regular function calls in the course of IR transformations.6//7// This is the case for ObjC ARC runtime intrinsics. Test that clang emits the8// funclet tokens for llvm.objc.* calls inside catch- and cleanup-pads and that9// they refer to their pad's SSA value.10 11void do_something();12void may_throw(id);13 14void try_catch_with_objc_intrinsic() {15 id ex;16 @try {17 may_throw(ex);18 } @catch (id ex_caught) {19 do_something();20 may_throw(ex_caught);21 }22}23 24// CHECK-LABEL: try_catch_with_objc_intrinsic25//26// CHECK: catch.dispatch:27// CHECK-NEXT: [[CATCHSWITCH:%[0-9]+]] = catchswitch within none [label %catch]28// CHECK-O0: unwind label %[[CLEANUP1:.*]]29// CHECK-O2: unwind to caller30//31// All calls within a catchpad must have funclet tokens that refer to it:32// CHECK: catch:33// CHECK-NEXT: [[CATCHPAD:%[0-9]+]] = catchpad within [[CATCHSWITCH]]34// CHECK: call35// CHECK: @llvm.objc.retain36// CHECK: [ "funclet"(token [[CATCHPAD]]) ]37// CHECK: invoke38// CHECK: do_something39// CHECK: [ "funclet"(token [[CATCHPAD]]) ]40// CHECK: unwind label %[[CLEANUP2:.*]]41// CHECK: invoke42// CHECK: may_throw43// CHECK: [ "funclet"(token [[CATCHPAD]]) ]44// CHECK: unwind label %[[CLEANUP2]]45// CHECK: call46// CHECK-O0: @llvm.objc.storeStrong47// CHECK-O2: @llvm.objc.release48// CHECK: [ "funclet"(token [[CATCHPAD]]) ]49// CHECK-O0: catchret from [[CATCHPAD]] to label %catchret.dest50// CHECK-O2: catchret from [[CATCHPAD]] to label %eh.cont51//52// In debug mode, this block exists and it's empty:53// CHECK-O0: catchret.dest:54// CHECK-O0-NEXT: br label %eh.cont55//56// CHECK: [[CLEANUP2]]:57// CHECK-NEXT: [[CLEANUPPAD2:%[0-9]+]] = cleanuppad within [[CATCHPAD]]58// CHECK: call59// CHECK-O0: @llvm.objc.storeStrong60// CHECK-O2: @llvm.objc.release61// CHECK: [ "funclet"(token [[CLEANUPPAD2]]) ]62// CHECK: cleanupret from [[CLEANUPPAD2]]63// CHECK-O0: unwind label %[[CLEANUP1]]64// CHECK-O2: unwind to caller65//66// CHECK-O0: [[CLEANUP1]]:67// CHECK-O0-NEXT: [[CLEANUPPAD1:%[0-9]+]] = cleanuppad within none68// CHECK-O0: call69// CHECK-O0: @llvm.objc.storeStrong70// CHECK-O0: [ "funclet"(token [[CLEANUPPAD1]]) ]71// CHECK-O0: cleanupret from [[CLEANUPPAD1]] unwind to caller72