Missing CHECK: lines makes test exit abnormally.
[oota-llvm.git] / test / Transforms / InstCombine / call.ll
1 ; Ignore stderr, we expect warnings there
2 ; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s
3
4
5 ; Simple case, argument translatable without changing the value
6 declare void @test1a(i8*)
7
8 define void @test1(i32* %A) {
9         call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
10         ret void
11 ; CHECK: %tmp = bitcast i32* %A to i8*
12 ; CHECK: call void @test1a(i8* %tmp)
13 ; CHECK: ret void
14 }
15
16 ; More complex case, translate argument because of resolution.  This is safe 
17 ; because we have the body of the function
18 define void @test2a(i8 %A) {
19         ret void
20 ; CHECK: ret void
21 }
22
23 define i32 @test2(i32 %A) {
24         call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
25         ret i32 %A
26 ; CHECK: %tmp = trunc i32 %A to i8
27 ; CHECK: call void @test2a(i8 %tmp)
28 ; CHECK: ret i32 %A
29 }
30
31
32 ; Resolving this should insert a cast from sbyte to int, following the C 
33 ; promotion rules.
34 declare void @test3a(i8, ...)
35
36 define void @test3(i8 %A, i8 %B) {
37         call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B 
38 )
39         ret void
40 ; CHECK: %tmp = zext i8 %B to i32
41 ; CHECK: call void (i8, ...)* @test3a(i8 %A, i32 %tmp)
42 ; CHECK: ret void
43 }
44
45
46 ; test conversion of return value...
47 define i8 @test4a() {
48         ret i8 0
49 ; CHECK: ret i8 0
50 }
51
52 define i32 @test4() {
53         %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( )            ; <i32> [#uses=1]
54         ret i32 %X
55 ; CHECK: %X1 = call i8 @test4a()
56 ; CHECK: %tmp = zext i8 %X1 to i32
57 ; CHECK: ret i32 %tmp
58 }
59
60
61 ; test conversion of return value... no value conversion occurs so we can do 
62 ; this with just a prototype...
63 declare i32 @test5a()
64
65 define i32 @test5() {
66         %X = call i32 @test5a( )                ; <i32> [#uses=1]
67         ret i32 %X
68 ; CHECK: %X = call i32 @test5a()
69 ; CHECK: ret i32 %X
70 }
71
72
73 ; test addition of new arguments...
74 declare i32 @test6a(i32)
75
76 define i32 @test6() {
77         %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( )                ; <i32> [#uses=1]
78         ret i32 %X
79 ; CHECK: %X1 = call i32 @test6a(i32 0)
80 ; CHECK: ret i32 %X1
81 }
82
83
84 ; test removal of arguments, only can happen with a function body
85 define void @test7a() {
86         ret void
87 ; CHECK: ret void
88 }
89
90 define void @test7() {
91         call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
92         ret void
93 ; CHECK: call void @test7a()
94 ; CHECK: ret void
95 }
96
97