Byebye llvm-upgrade!
[oota-llvm.git] / test / Transforms / InstCombine / call.ll
1 ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \
2 ; RUN:    grep call | notcast
3 ; END.
4
5
6 ; Simple case, argument translatable without changing the value
7 declare void @test1a(i8*)
8
9 define void @test1(i32* %A) {
10         call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
11         ret void
12 }
13
14 ; More complex case, translate argument because of resolution.  This is safe 
15 ; because we have the body of the function
16 define void @test2a(i8 %A) {
17         ret void
18 }
19
20 define i32 @test2(i32 %A) {
21         call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
22         ret i32 %A
23 }
24
25
26 ; Resolving this should insert a cast from sbyte to int, following the C 
27 ; promotion rules.
28 declare void @test3a(i8, ...)
29
30 define void @test3(i8 %A, i8 %B) {
31         call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B 
32 )
33         ret void
34 }
35
36
37 ; test conversion of return value...
38 define i8 @test4a() {
39         ret i8 0
40 }
41
42 define i32 @test4() {
43         %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( )            ; <i32> [#uses=1]
44         ret i32 %X
45 }
46
47
48 ; test conversion of return value... no value conversion occurs so we can do 
49 ; this with just a prototype...
50 declare i32 @test5a()
51
52 define i32 @test5() {
53         %X = call i32 @test5a( )                ; <i32> [#uses=1]
54         ret i32 %X
55 }
56
57
58 ; test addition of new arguments...
59 declare i32 @test6a(i32)
60
61 define i32 @test6() {
62         %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( )                ; <i32> [#uses=1]
63         ret i32 %X
64 }
65
66
67 ; test removal of arguments, only can happen with a function body
68 define void @test7a() {
69         ret void
70 }
71
72 define void @test7() {
73         call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
74         ret void
75 }
76
77