[WinEH] Teach AsmPrinter about funclets
[oota-llvm.git] / test / CodeGen / X86 / seh-finally.ll
1 ; RUN: llc -mtriple=x86_64-windows-msvc < %s | FileCheck %s --check-prefix=X64
2 ; RUN: sed -e 's/__C_specific_handler/_except_handler3/' %s | \
3 ; RUN:        llc -mtriple=i686-windows-msvc | FileCheck %s --check-prefix=X86
4
5 @str_recovered = internal unnamed_addr constant [10 x i8] c"recovered\00", align 1
6
7 declare void @crash()
8
9 define i32 @main() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
10 entry:
11   invoke void @crash()
12           to label %invoke.cont unwind label %lpad
13
14 invoke.cont:                                      ; preds = %entry
15   %call = call i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str_recovered, i64 0, i64 0))
16   call void @abort()
17   ret i32 0
18
19 lpad:                                             ; preds = %entry
20   %0 = landingpad { i8*, i32 }
21           cleanup
22   %1 = extractvalue { i8*, i32 } %0, 0
23   %2 = extractvalue { i8*, i32 } %0, 1
24   %call2 = invoke i32 @puts(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @str_recovered, i64 0, i64 0))
25           to label %invoke.cont1 unwind label %terminate.lpad
26
27 invoke.cont1:                                     ; preds = %lpad
28   resume { i8*, i32 } %0
29
30 terminate.lpad:                                   ; preds = %lpad
31   %3 = landingpad { i8*, i32 }
32           catch i8* null
33   call void @abort()
34   unreachable
35 }
36
37 ; X64-LABEL: main:
38 ; X64: retq
39
40 ; X64: .seh_handlerdata
41 ; X64-NEXT: .text
42 ; X64-NEXT: .Ltmp{{[0-9]+}}:
43 ; X64-NEXT: .seh_endproc
44 ; X64-NEXT: .section .xdata,"dr"
45 ; X64-NEXT: .long 1
46 ; X64-NEXT: .long .Ltmp0@IMGREL
47 ; X64-NEXT: .long .Ltmp1@IMGREL
48 ; X64-NEXT: .long main.cleanup@IMGREL
49 ; X64-NEXT: .long 0
50
51 ; X64-LABEL: main.cleanup:
52 ; X64: callq puts
53 ; X64: retq
54
55 ; X86-LABEL: _main:
56 ; X86: retl
57
58 ; X86: .section .xdata,"dr"
59 ; X86: L__ehtable$main:
60 ; X86-NEXT: .long -1
61 ; X86-NEXT: .long 0
62 ; X86-NEXT: .long _main.cleanup
63
64 ; X86-LABEL: _main.cleanup:
65 ; X86: calll _puts
66 ; X86: retl
67
68 declare i32 @__C_specific_handler(...)
69
70 declare i32 @puts(i8*)
71
72 declare void @abort()