[WinEH] Teach AsmPrinter about funclets
[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 @__C_specific_handler(...)
6 declare void @crash()
7 declare i32 @printf(i8* nocapture readonly, ...) nounwind
8
9 define i32 @main() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
10 entry:
11   invoke void @crash()
12           to label %__try.cont unwind label %lpad
13
14 lpad:
15   %0 = landingpad { i8*, i32 }
16           catch i8* null
17   %1 = extractvalue { i8*, i32 } %0, 0
18   %2 = ptrtoint i8* %1 to i64
19   %3 = trunc i64 %2 to i32
20   call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i32 %3)
21   br label %__try.cont
22
23 __try.cont:
24   ret i32 0
25
26 eh.resume:
27   resume { i8*, i32 } %0
28 }
29
30 ; Check that we can get the exception code from eax to the printf.
31
32 ; CHECK-LABEL: main:
33 ; CHECK: callq crash
34 ; CHECK: retq
35 ; CHECK: # Block address taken
36 ; CHECK: leaq str(%rip), %rcx
37 ; CHECK: movl %eax, %edx
38 ; CHECK: callq printf
39
40 ; CHECK: .seh_handlerdata
41 ; CHECK-NEXT: .text
42 ; CHECK-NEXT: .Ltmp{{[0-9]+}}
43 ; CHECK-NEXT: .seh_endproc
44 ; CHECK-NEXT: .section .xdata,"dr"
45 ; CHECK-NEXT: .long 1
46 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
47 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL+1
48 ; CHECK-NEXT: .long 1
49 ; CHECK-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL