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
5 @str = linkonce_odr unnamed_addr constant [27 x i8] c"GetExceptionCode(): 0x%lx\0A\00", align 1
7 declare i32 @__C_specific_handler(...)
9 declare i32 @printf(i8* nocapture readonly, ...) nounwind
14 to label %__try.cont unwind label %lpad
17 %0 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*)
19 %1 = extractvalue { i8*, i32 } %0, 0
20 %2 = ptrtoint i8* %1 to i64
21 %3 = trunc i64 %2 to i32
22 call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @str, i64 0, i64 0), i32 %3)
29 resume { i8*, i32 } %0
32 ; Check that we can get the exception code from eax to the printf.
37 ; X64: # Block address taken
38 ; X64: leaq str(%rip), %rcx
39 ; X64: movl %eax, %edx
42 ; X64: .seh_handlerdata
44 ; X64-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
45 ; X64-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL+1
47 ; X64-NEXT: .long .Ltmp{{[0-9]+}}@IMGREL
50 ; The EH code load should be this offset +4.
51 ; X86: movl %esp, -24(%ebp)
52 ; X86: movl $L__ehtable$main,
54 ; X86: movl $0, -4(%ebp)
57 ; X86: # Block address taken
58 ; X86: movl -20(%ebp), %[[ptrs:[^ ,]*]]
59 ; X86: movl (%[[ptrs]]), %[[rec:[^ ,]*]]
60 ; X86: movl (%[[rec]]), %[[code:[^ ,]*]]
62 ; X86: movl $-1, -4(%ebp)
63 ; X86-DAG: movl %[[code]], 4(%esp)
64 ; X86-DAG: movl $_str, (%esp)
67 ; X86: .section .xdata,"dr"
68 ; X86-NEXT: L__ehtable$main
71 ; X86-NEXT: .long Ltmp{{[0-9]+}}