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
4 implementation
5
6 ; Simple case, argument translatable without changing the value
7 declare void %test1a(sbyte *%A) 
8 void %test1(int *%A) {
9         call void(int*)* cast (void(sbyte*)* %test1a to void(int*)*)(int* %A)
10         ret void
11 }
12
13 ; More complex case, translate argument because of resolution.  This is safe 
14 ; because we have the body of the function
15 void %test2a(sbyte %A) { ret void }
16 int %test2(int %A) {
17         call void(int)* cast (void(sbyte)* %test2a to void(int)*)(int %A)
18         ret int %A
19 }
20
21 ; Resolving this should insert a cast from sbyte to int, following the C 
22 ; promotion rules.
23 declare void %test3a(sbyte %A, ...)
24 void %test3(sbyte %A, sbyte %B) {
25         call void(sbyte, sbyte)* cast (void(sbyte,...)* %test3a to void(sbyte,sbyte)*)(sbyte %A, sbyte %B)
26         ret void
27 }
28
29 ; test conversion of return value...
30 sbyte %test4a() { ret sbyte 0 }
31 int %test4() {
32         %X = call int()* cast (sbyte()* %test4a to int()*)()
33         ret int %X
34 }
35
36 ; test conversion of return value... no value conversion occurs so we can do 
37 ; this with just a prototype...
38 declare uint %test5a()
39 int %test5() {
40         %X = call int()* cast (uint()* %test5a to int()*)()
41         ret int %X
42 }
43
44 ; test addition of new arguments...
45 declare int %test6a(int %X)
46 int %test6() {
47         %X = call int()* cast (int(int)* %test6a to int()*)()
48         ret int %X
49 }
50
51 ; test removal of arguments, only can happen with a function body
52 void %test7a() { ret void } 
53 void %test7() {
54         call void(int)* cast (void()* %test7a to void(int)*)(int 5)
55         ret void
56 }
57