[SEH] Update SEH codegen tests to use the new IR
[oota-llvm.git] / test / CodeGen / WinEH / seh-exception-code.ll
1 ; RUN: opt -winehprepare -S < %s | FileCheck %s
2
3 ; WinEHPrepare was crashing during phi demotion.
4
5 target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128"
6 target triple = "x86_64-pc-windows-msvc18.0.0"
7
8 declare i32 @__C_specific_handler(...)
9
10 @str = linkonce_odr unnamed_addr constant [16 x i8] c"caught it! %lx\0A\00", align 1
11
12 ; Function Attrs: nounwind uwtable
13 declare void @maycrash()
14
15 ; Function Attrs: nounwind
16 declare i32 @printf(i8* nocapture readonly, ...)
17
18 ; Function Attrs: nounwind uwtable
19 define void @doit() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
20 entry:
21   invoke void @maycrash()
22           to label %invoke.cont unwind label %lpad
23
24 invoke.cont:                                      ; preds = %entry
25   invoke void @maycrash()
26           to label %__try.cont unwind label %lpad.1
27
28 lpad:                                             ; preds = %entry
29   %0 = landingpad { i8*, i32 }
30           catch i8* null
31   %1 = extractvalue { i8*, i32 } %0, 0
32   br label %__except
33
34 lpad.1:                                           ; preds = %invoke.cont, %lpad
35   %2 = landingpad { i8*, i32 }
36           catch i8* null
37   %3 = extractvalue { i8*, i32 } %2, 0
38   br label %__except
39
40 __except:                                         ; preds = %lpad, %lpad.1
41   %exn.slot.0 = phi i8* [ %3, %lpad.1 ], [ %1, %lpad ]
42   %4 = ptrtoint i8* %exn.slot.0 to i64
43   %5 = trunc i64 %4 to i32
44   %call = tail call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @str, i64 0, i64 0), i32 %5)
45   br label %__try.cont
46
47 __try.cont:                                       ; preds = %invoke.cont, %__except
48   ret void
49 }
50
51 ; CHECK-LABEL: define void @doit()
52 ; CHECK: landingpad
53 ; CHECK: indirectbr i8* %{{[^,]*}}, [label %[[except_split1:.*]]]
54 ; CHECK: [[except_split1]]:
55 ; CHECK: call i32 @llvm.eh.exceptioncode.old()
56 ; CHECK: br label %__except
57 ;
58 ; CHECK: landingpad
59 ; CHECK: indirectbr i8* %{{[^,]*}}, [label %[[except_split2:.*]]]
60 ; CHECK: [[except_split2]]:
61 ; CHECK: call i32 @llvm.eh.exceptioncode.old()
62 ; CHECK: br label %__except
63 ;
64 ; CHECK: __except:
65 ; CHECK: phi
66 ; CHECK: call i32 (i8*, ...) @printf