summaryrefslogtreecommitdiff
path: root/test/Transforms/LowerSetJmp/simpletest.ll
blob: d749d5ff13458b4be24c6d96a8e8d2f58fedae54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
; RUN: llvm-upgrade < %s | llvm-as | opt -lowersetjmp | llvm-dis | grep invoke

%JmpBuf = type int
%.str_1 = internal constant [13 x sbyte] c"returned %d\0A\00"

implementation

declare void %llvm.longjmp(%JmpBuf *%B, int %Val)
declare int %llvm.setjmp(%JmpBuf *%B)

declare void %foo()

int %simpletest() {
	%B = alloca %JmpBuf
	%Val = call int %llvm.setjmp(%JmpBuf* %B)
	%V = cast int %Val to bool
	br bool %V, label %LongJumped, label %Normal
Normal:
	call void %foo()
	call void %llvm.longjmp(%JmpBuf* %B, int 42)
	ret int 0 ;; not reached
LongJumped:
	ret int %Val
}

declare int %printf(sbyte*, ...)

int %main() {
	%V = call int %simpletest()
	call int(sbyte*, ...)* %printf(sbyte* getelementptr ([13 x sbyte]* %.str_1, long 0, long 0), int %V)
	ret int 0
}