Move the personality function from LandingPadInst to Function
[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: .long 1
42 ; X64-NEXT: .long .Ltmp0@IMGREL
43 ; X64-NEXT: .long .Ltmp1@IMGREL
44 ; X64-NEXT: .long main.cleanup@IMGREL
45 ; X64-NEXT: .long 0
46
47 ; X64-LABEL: main.cleanup:
48 ; X64: callq puts
49 ; X64: retq
50
51 ; X86-LABEL: _main:
52 ; X86: retl
53
54 ; X86: .section .xdata,"dr"
55 ; X86: L__ehtable$main:
56 ; X86-NEXT: .long -1
57 ; X86-NEXT: .long 0
58 ; X86-NEXT: .long _main.cleanup
59
60 ; X86-LABEL: _main.cleanup:
61 ; X86: calll _puts
62 ; X86: retl
63
64 declare i32 @__C_specific_handler(...)
65
66 declare i32 @puts(i8*)
67
68 declare void @abort()