xref: /minix3/external/bsd/llvm/dist/llvm/test/ExecutionEngine/MCJIT/2005-12-02-TailCallBug.ll (revision 0a6a1f1d05b60e214de2f05a7310ddd1f0e590e7)
1f4a2713aSLionel Sambuc; PR672
2*0a6a1f1dSLionel Sambuc; RUN: %lli %s
3f4a2713aSLionel Sambuc; XFAIL: mcjit-ia32
4f4a2713aSLionel Sambuc
5f4a2713aSLionel Sambucdefine i32 @main() {
6f4a2713aSLionel Sambuc	%f = bitcast i32 (i32, i32*, i32)* @check_tail to i32*		; <i32*> [#uses=1]
7f4a2713aSLionel Sambuc	%res = tail call fastcc i32 @check_tail( i32 10, i32* %f, i32 10 )		; <i32> [#uses=1]
8f4a2713aSLionel Sambuc	ret i32 %res
9f4a2713aSLionel Sambuc}
10f4a2713aSLionel Sambuc
11f4a2713aSLionel Sambucdefine fastcc i32 @check_tail(i32 %x, i32* %f, i32 %g) {
12f4a2713aSLionel Sambuc	%tmp1 = icmp sgt i32 %x, 0		; <i1> [#uses=1]
13f4a2713aSLionel Sambuc	br i1 %tmp1, label %if-then, label %if-else
14f4a2713aSLionel Sambucif-then:		; preds = %0
15f4a2713aSLionel Sambuc	%fun_ptr = bitcast i32* %f to i32 (i32, i32*, i32)*		; <i32 (i32, i32*, i32)*> [#uses=1]
16f4a2713aSLionel Sambuc	%arg1 = add i32 %x, -1		; <i32> [#uses=1]
17f4a2713aSLionel Sambuc	%res = tail call fastcc i32 %fun_ptr( i32 %arg1, i32* %f, i32 %g )		; <i32> [#uses=1]
18f4a2713aSLionel Sambuc	ret i32 %res
19f4a2713aSLionel Sambucif-else:		; preds = %0
20f4a2713aSLionel Sambuc	ret i32 %x
21f4a2713aSLionel Sambuc}
22f4a2713aSLionel Sambuc
23