1 ; RUN: opt -mtriple=i686-pc-windows-msvc -S -x86-winehstate < %s | FileCheck %s
2 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
3 target triple = "i686-pc-windows-msvc"
5 @jb = external global i8
7 define i32 @test1() personality ptr @__CxxFrameHandler3 {
9 ; CHECK-LABEL: define i32 @test1(
10 ; CHECK: %[[eh_reg:.*]] = alloca
11 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 2
12 ; CHECK: store i32 -1, ptr %[[gep]]
13 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 2
14 ; CHECK: store i32 0, ptr %[[gep]]
15 ; CHECK: %[[lsda:.*]] = call ptr @llvm.x86.seh.lsda(ptr @test1)
16 ; CHECK: invoke i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 3, ptr @__CxxLongjmpUnwind, i32 0, ptr %[[lsda]])
17 %inv = invoke i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 0) #2
18 to label %invoke.cont unwind label %ehcleanup
21 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 2
22 ; CHECK: store i32 -1, ptr %[[gep]]
23 ; CHECK: %[[lsda:.*]] = call ptr @llvm.x86.seh.lsda(ptr @test1)
24 ; CHECK: call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 3, ptr @__CxxLongjmpUnwind, i32 -1, ptr %[[lsda]])
25 call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 0)
30 %cp = cleanuppad within none []
31 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 2
32 ; CHECK: %[[load:.*]] = load i32, ptr %[[gep]]
33 ; CHECK: %[[lsda:.*]] = call ptr @llvm.x86.seh.lsda(ptr @test1)
34 ; CHECK: call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 3, ptr @__CxxLongjmpUnwind, i32 %[[load]], ptr %[[lsda]]) [ "funclet"(token %cp) ]
35 %cal = call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 0) [ "funclet"(token %cp) ]
36 call void @cleanup() [ "funclet"(token %cp) ]
37 cleanupret from %cp unwind to caller
40 define i32 @test2() personality ptr @_except_handler3 {
42 ; CHECK-LABEL: define i32 @test2(
43 ; CHECK: %[[eh_reg:.*]] = alloca
44 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 4
45 ; CHECK: store i32 -1, ptr %[[gep]]
46 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 4
47 ; CHECK: store i32 0, ptr %[[gep]]
48 ; CHECK: invoke i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 2, ptr @_seh_longjmp_unwind, i32 0)
49 %inv = invoke i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 0) #2
50 to label %invoke.cont unwind label %ehcleanup
53 ; CHECK: %[[gep:.*]] = getelementptr inbounds {{.*}}, {{.*}} %[[eh_reg]], i32 0, i32 4
54 ; CHECK: store i32 -1, ptr %[[gep]]
55 ; CHECK: call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 2, ptr @_seh_longjmp_unwind, i32 -1)
56 call i32 (ptr, i32, ...) @_setjmp3(ptr @jb, i32 0)
61 %cp = cleanuppad within none []
62 call void @cleanup() [ "funclet"(token %cp) ]
63 cleanupret from %cp unwind to caller
66 ; Function Attrs: returns_twice
67 declare i32 @_setjmp3(ptr, i32, ...) #2
69 declare i32 @__CxxFrameHandler3(...)
71 declare i32 @_except_handler3(...)
73 declare void @cleanup()
75 attributes #2 = { returns_twice }