For PR1319:
[oota-llvm.git] / test / Transforms / InstCombine / call.ll
1 ; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \
2 ; RUN:    grep call | notcast
3 ; END.
4
5 implementation
6
7 ; Simple case, argument translatable without changing the value
8 declare void %test1a(sbyte *%A) 
9 void %test1(int *%A) {
10         call void(int*)* cast (void(sbyte*)* %test1a to void(int*)*)(int* %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 void %test2a(sbyte %A) { ret void }
17 int %test2(int %A) {
18         call void(int)* cast (void(sbyte)* %test2a to void(int)*)(int %A)
19         ret int %A
20 }
21
22 ; Resolving this should insert a cast from sbyte to int, following the C 
23 ; promotion rules.
24 declare void %test3a(sbyte %A, ...)
25 void %test3(sbyte %A, sbyte %B) {
26         call void(sbyte, sbyte)* cast (void(sbyte,...)* %test3a to void(sbyte,sbyte)*)(sbyte %A, sbyte %B)
27         ret void
28 }
29
30 ; test conversion of return value...
31 sbyte %test4a() { ret sbyte 0 }
32 int %test4() {
33         %X = call int()* cast (sbyte()* %test4a to int()*)()
34         ret int %X
35 }
36
37 ; test conversion of return value... no value conversion occurs so we can do 
38 ; this with just a prototype...
39 declare uint %test5a()
40 int %test5() {
41         %X = call int()* cast (uint()* %test5a to int()*)()
42         ret int %X
43 }
44
45 ; test addition of new arguments...
46 declare int %test6a(int %X)
47 int %test6() {
48         %X = call int()* cast (int(int)* %test6a to int()*)()
49         ret int %X
50 }
51
52 ; test removal of arguments, only can happen with a function body
53 void %test7a() { ret void } 
54 void %test7() {
55         call void(int)* cast (void()* %test7a to void(int)*)(int 5)
56         ret void
57 }
58