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