blob: 1430dffdfe3fc829d6728ff43ca330e80671fae5 [file] [log] [blame]
Dan Gohman3c7d3082009-09-11 18:01:28 +00001; RUN: opt < %s -lowersetjmp -S | grep invoke
Dan Gohmanf17a25c2007-07-18 16:29:46 +00002
Tanya Lattner97928372008-03-19 07:28:33 +00003 %JmpBuf = type i32
4@.str_1 = internal constant [13 x i8] c"returned %d\0A\00" ; <[13 x i8]*> [#uses=1]
Dan Gohmanf17a25c2007-07-18 16:29:46 +00005
Tanya Lattner97928372008-03-19 07:28:33 +00006declare void @llvm.longjmp(i32*, i32)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00007
Tanya Lattner97928372008-03-19 07:28:33 +00008declare i32 @llvm.setjmp(i32*)
Dan Gohmanf17a25c2007-07-18 16:29:46 +00009
Tanya Lattner97928372008-03-19 07:28:33 +000010declare void @foo()
Dan Gohmanf17a25c2007-07-18 16:29:46 +000011
Tanya Lattner97928372008-03-19 07:28:33 +000012define i32 @simpletest() {
13 %B = alloca i32 ; <i32*> [#uses=2]
14 %Val = call i32 @llvm.setjmp( i32* %B ) ; <i32> [#uses=2]
15 %V = icmp ne i32 %Val, 0 ; <i1> [#uses=1]
16 br i1 %V, label %LongJumped, label %Normal
17Normal: ; preds = %0
18 call void @foo( )
19 call void @llvm.longjmp( i32* %B, i32 42 )
20 ret i32 0
21LongJumped: ; preds = %0
22 ret i32 %Val
Dan Gohmanf17a25c2007-07-18 16:29:46 +000023}
24
Tanya Lattner97928372008-03-19 07:28:33 +000025declare i32 @printf(i8*, ...)
Dan Gohmanf17a25c2007-07-18 16:29:46 +000026
Tanya Lattner97928372008-03-19 07:28:33 +000027define i32 @main() {
28 %V = call i32 @simpletest( ) ; <i32> [#uses=1]
29 call i32 (i8*, ...)* @printf( i8* getelementptr ([13 x i8]* @.str_1, i64 0, i64 0), i32 %V ) ; <i32>:1 [#uses=0]
30 ret i32 0
Dan Gohmanf17a25c2007-07-18 16:29:46 +000031}
Tanya Lattner97928372008-03-19 07:28:33 +000032