1 ; Ignore stderr, we expect warnings there
2 ; RUN: opt < %s -instcombine 2> /dev/null -S | FileCheck %s
5 ; Simple case, argument translatable without changing the value
6 declare void @test1a(i8*)
8 define void @test1(i32* %A) {
9 call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
11 ; CHECK: %tmp = bitcast i32* %A to i8*
12 ; CHECK: call void @test1a(i8* %tmp)
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) {
23 define i32 @test2(i32 %A) {
24 call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
26 ; CHECK: %tmp = trunc i32 %A to i8
27 ; CHECK: call void @test2a(i8 %tmp)
32 ; Resolving this should insert a cast from sbyte to int, following the C
34 declare void @test3a(i8, ...)
36 define void @test3(i8 %A, i8 %B) {
37 call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B
40 ; CHECK: %tmp = zext i8 %B to i32
41 ; CHECK: call void (i8, ...)* @test3a(i8 %A, i32 %tmp)
46 ; test conversion of return value...
53 %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; <i32> [#uses=1]
55 ; CHECK: %X1 = call i8 @test4a()
56 ; CHECK: %tmp = zext i8 %X1 to i32
61 ; test conversion of return value... no value conversion occurs so we can do
62 ; this with just a prototype...
66 %X = call i32 @test5a( ) ; <i32> [#uses=1]
68 ; CHECK: %X = call i32 @test5a()
73 ; test addition of new arguments...
74 declare i32 @test6a(i32)
77 %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( ) ; <i32> [#uses=1]
79 ; CHECK: %X1 = call i32 @test6a(i32 0)
84 ; test removal of arguments, only can happen with a function body
85 define void @test7a() {
90 define void @test7() {
91 call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
93 ; CHECK: call void @test7a()