[WinEH] Add missing test case for llvm.eh.exceptioncode
[oota-llvm.git] / test / CodeGen / X86 / seh-exception-code.ll
1 ; RUN: llc < %s | FileCheck %s
2
3 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
4 target triple = "x86_64-pc-windows-msvc"
5
6 declare void @f(i32)
7 declare i32 @__C_specific_handler(...)
8 declare i32 @llvm.eh.exceptioncode(token)
9
10 define void @ehcode() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
11 entry:
12   invoke void @f(i32 0)
13           to label %__try.cont unwind label %catch.dispatch
14
15 catch.dispatch:                                   ; preds = %entry
16   %pad = catchpad [i8* null]
17           to label %__except unwind label %catchendblock
18
19 __except:                                         ; preds = %catch.dispatch
20   catchret %pad to label %__except.1
21
22 __except.1:                                       ; preds = %__except
23   %code = call i32 @llvm.eh.exceptioncode(token %pad)
24   call void @f(i32 %code)
25   br label %__try.cont
26
27 __try.cont:                                       ; preds = %entry, %__except.1
28   ret void
29
30 catchendblock:                                    ; preds = %catch.dispatch
31   catchendpad unwind to caller
32 }
33
34 ; CHECK-LABEL: ehcode:
35 ; CHECK: xorl %ecx, %ecx
36 ; CHECK: callq f
37 ; CHECK: retq
38
39 ; CHECK: # %__except
40 ; CHECK-NEXT: movl %eax, %ecx
41 ; CHECK-NEXT: callq f