05139ef1bd9ddfab16b81e8b7ec6e43e256a0cba
[oota-llvm.git] / test / CodeGen / WinEH / wineh-exceptionpointer.ll
1 ; RUN: llc -mtriple=x86_64-pc-windows-coreclr < %s | FileCheck %s
2
3 declare void @ProcessCLRException()
4 declare i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token)
5 declare void @f()
6 declare void @g(i32 addrspace(1)*)
7
8 ; CHECK-LABEL: test1: # @test1
9 define void @test1() personality i8* bitcast (void ()* @ProcessCLRException to i8*) {
10 entry:
11   invoke void @f()
12     to label %exit unwind label %catch.pad
13 catch.pad:
14 ; CHECK: {{^[^: ]+}}: # %catch.pad
15   %catch = catchpad [i32 5]
16     to label %catch.body unwind label %catch.end
17 catch.body:
18   %exn = call i8 addrspace(1)* @llvm.eh.exceptionpointer.p1i8(token %catch)
19   %cast_exn = bitcast i8 addrspace(1)* %exn to i32 addrspace(1)*
20   ; CHECK: movq %rax, %rcx
21   ; CHECK-NEXT: callq g
22   call void @g(i32 addrspace(1)* %cast_exn)
23   catchret %catch to label %exit
24 catch.end:
25   catchendpad unwind to caller
26 exit:
27   ret void
28 }