xref: /aosp_15_r20/external/llvm/test/CodeGen/WinEH/wineh-intrinsics.ll (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker; RUN: opt -lint -disable-output < %s
2*9880d681SAndroid Build Coastguard Worker
3*9880d681SAndroid Build Coastguard Worker; This test is meant to prove that the verifier does not report errors for correct
4*9880d681SAndroid Build Coastguard Worker; use of the llvm.eh.exceptionpointer intrinsic.
5*9880d681SAndroid Build Coastguard Worker
6*9880d681SAndroid Build Coastguard Workertarget triple = "x86_64-pc-windows-msvc"
7*9880d681SAndroid Build Coastguard Worker
8*9880d681SAndroid Build Coastguard Workerdeclare i8* @llvm.eh.exceptionpointer.p0i8(token)
9*9880d681SAndroid Build Coastguard Workerdeclare i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token)
10*9880d681SAndroid Build Coastguard Worker
11*9880d681SAndroid Build Coastguard Workerdeclare void @f(...)
12*9880d681SAndroid Build Coastguard Worker
13*9880d681SAndroid Build Coastguard Workerdefine void @test1() personality i32 (...)* @__CxxFrameHandler3 {
14*9880d681SAndroid Build Coastguard Workerentry:
15*9880d681SAndroid Build Coastguard Worker  invoke void (...) @f(i32 1)
16*9880d681SAndroid Build Coastguard Worker     to label %exit unwind label %catchpad
17*9880d681SAndroid Build Coastguard Workercatchpad:
18*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %do_catch] unwind to caller
19*9880d681SAndroid Build Coastguard Workerdo_catch:
20*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i32 1]
21*9880d681SAndroid Build Coastguard Worker  %exn = call i8* @llvm.eh.exceptionpointer.p0i8(token %catch)
22*9880d681SAndroid Build Coastguard Worker  call void (...) @f(i8* %exn)
23*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
24*9880d681SAndroid Build Coastguard Workerexit:
25*9880d681SAndroid Build Coastguard Worker  ret void
26*9880d681SAndroid Build Coastguard Worker}
27*9880d681SAndroid Build Coastguard Worker
28*9880d681SAndroid Build Coastguard Workerdefine void @test2() personality i32 (...)* @ProcessManagedException {
29*9880d681SAndroid Build Coastguard Workerentry:
30*9880d681SAndroid Build Coastguard Worker  invoke void (...) @f(i32 1)
31*9880d681SAndroid Build Coastguard Worker     to label %exit unwind label %catchpad
32*9880d681SAndroid Build Coastguard Workercatchpad:
33*9880d681SAndroid Build Coastguard Worker  %cs1 = catchswitch within none [label %do_catch] unwind to caller
34*9880d681SAndroid Build Coastguard Workerdo_catch:
35*9880d681SAndroid Build Coastguard Worker  %catch = catchpad within %cs1 [i32 1]
36*9880d681SAndroid Build Coastguard Worker  %exn = call i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token %catch)
37*9880d681SAndroid Build Coastguard Worker  call void (...) @f(i8 addrspace(1)* %exn)
38*9880d681SAndroid Build Coastguard Worker  catchret from %catch to label %exit
39*9880d681SAndroid Build Coastguard Workerexit:
40*9880d681SAndroid Build Coastguard Worker  ret void
41*9880d681SAndroid Build Coastguard Worker}
42*9880d681SAndroid Build Coastguard Worker
43*9880d681SAndroid Build Coastguard Workerdeclare i32 @__CxxFrameHandler3(...)
44*9880d681SAndroid Build Coastguard Workerdeclare i32 @ProcessManagedException(...)
45