File: arc-exceptions-seh.mm

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (71 lines) | stat: -rw-r--r-- 3,011 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// 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-O0
// 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-O2

// WinEH requires funclet tokens on nounwind intrinsics if they can lower to
// regular function calls in the course of IR transformations.
//
// This is the case for ObjC ARC runtime intrinsics. Test that clang emits the
// funclet tokens for llvm.objc.* calls inside catch- and cleanup-pads and that
// they refer to their pad's SSA value.

void do_something();
void may_throw(id);

void try_catch_with_objc_intrinsic() {
  id ex;
  @try {
    may_throw(ex);
  } @catch (id ex_caught) {
    do_something();
    may_throw(ex_caught);
  }
}

// CHECK-LABEL:   try_catch_with_objc_intrinsic
//
// CHECK:         catch.dispatch:
// CHECK-NEXT:      [[CATCHSWITCH:%[0-9]+]] = catchswitch within none [label %catch]
// CHECK-O0:          unwind label %[[CLEANUP1:.*]]
// CHECK-O2:          unwind to caller
//
// All calls within a catchpad must have funclet tokens that refer to it:
// CHECK:         catch:
// CHECK-NEXT:      [[CATCHPAD:%[0-9]+]] = catchpad within [[CATCHSWITCH]]
// CHECK:           call
// CHECK:             @llvm.objc.retain
// CHECK:             [ "funclet"(token [[CATCHPAD]]) ]
// CHECK:           invoke
// CHECK:             do_something
// CHECK:             [ "funclet"(token [[CATCHPAD]]) ]
// CHECK:             unwind label %[[CLEANUP2:.*]]
// CHECK:           invoke
// CHECK:             may_throw
// CHECK:             [ "funclet"(token [[CATCHPAD]]) ]
// CHECK:             unwind label %[[CLEANUP2]]
// CHECK:           call
// CHECK-O0:          @llvm.objc.storeStrong
// CHECK-O2:          @llvm.objc.release
// CHECK:             [ "funclet"(token [[CATCHPAD]]) ]
// CHECK-O0:        catchret from [[CATCHPAD]] to label %catchret.dest
// CHECK-O2:        catchret from [[CATCHPAD]] to label %eh.cont
//
// In debug mode, this block exists and it's empty:
// CHECK-O0:      catchret.dest:
// CHECK-O0-NEXT:   br label %eh.cont
//
// CHECK:         [[CLEANUP2]]:
// CHECK-NEXT:      [[CLEANUPPAD2:%[0-9]+]] = cleanuppad within [[CATCHPAD]]
// CHECK:           call
// CHECK-O0:          @llvm.objc.storeStrong
// CHECK-O2:          @llvm.objc.release
// CHECK:             [ "funclet"(token [[CLEANUPPAD2]]) ]
// CHECK:           cleanupret from [[CLEANUPPAD2]]
// CHECK-O0:          unwind label %[[CLEANUP1]]
// CHECK-O2:          unwind to caller
//
// CHECK-O0:      [[CLEANUP1]]:
// CHECK-O0-NEXT:   [[CLEANUPPAD1:%[0-9]+]] = cleanuppad within none
// CHECK-O0:        call
// CHECK-O0:          @llvm.objc.storeStrong
// CHECK-O0:          [ "funclet"(token [[CLEANUPPAD1]]) ]
// CHECK-O0:        cleanupret from [[CLEANUPPAD1]] unwind to caller