[WinEH] Don't emit CATCHRET from visitCatchPad
[oota-llvm.git] / test / CodeGen / X86 / seh-catch-all.ll
1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s
2
3 @str = linkonce_odr unnamed_addr constant [27 x i8] c"GetExceptionCode(): 0x%lx\0A\00", align 1
4
5 declare i32 @llvm.eh.exceptioncode(token)
6 declare i32 @__C_specific_handler(...)
7 declare void @crash()
8 declare i32 @printf(i8* nocapture readonly, ...) nounwind
9
10 define i32 @main() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
11 entry:
12   invoke void @crash()
13           to label %__try.cont unwind label %lpad
14
15 __try.cont:
16   ret i32 0
17
18 lpad:
19   %p = catchpad [i8* null, i32 64, i8* null]
20           to label %catchall unwind label %endpad
21
22 catchall:
23   %code = call i32 @llvm.eh.exceptioncode(token %p)
24   call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i32 %code)
25   catchret %p to label %__try.cont
26
27 endpad:
28   catchendpad unwind to caller
29 }
30
31 ; Check that we can get the exception code from eax to the printf.
32
33 ; CHECK-LABEL: main:
34 ; CHECK: callq crash
35 ; CHECK: retq
36 ; CHECK: .LBB0_2: # %lpad
37 ; CHECK: leaq str(%rip), %rcx
38 ; CHECK: movl %eax, %edx
39 ; CHECK: callq printf
40
41 ; CHECK: .seh_handlerdata
42 ; CHECK-NEXT: .long (.Llsda_end0-.Llsda_begin0)/16
43 ; CHECK-NEXT: .Llsda_begin0:
44 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
45 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL+1
46 ; CHECK-NEXT: .long 1
47 ; CHECK-NEXT: .long .LBB0_2@IMGREL
48 ; CHECK-NEXT: .Llsda_end0: