2008-06-10 16:13:38 +00:00
|
|
|
; Ignore stderr, we expect warnings there
|
|
|
|
; RUN: llvm-as < %s 2> /dev/null | opt -instcombine | llvm-dis | \
|
2007-04-14 20:13:02 +00:00
|
|
|
; RUN: grep call | notcast
|
2007-04-15 07:38:21 +00:00
|
|
|
; END.
|
2003-06-18 22:48:11 +00:00
|
|
|
|
|
|
|
|
|
|
|
; Simple case, argument translatable without changing the value
|
2008-03-25 04:26:08 +00:00
|
|
|
declare void @test1a(i8*)
|
|
|
|
|
|
|
|
define void @test1(i32* %A) {
|
|
|
|
call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A )
|
2003-06-18 22:48:11 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
; More complex case, translate argument because of resolution. This is safe
|
|
|
|
; because we have the body of the function
|
2008-03-25 04:26:08 +00:00
|
|
|
define void @test2a(i8 %A) {
|
|
|
|
ret void
|
2003-06-18 22:48:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
define i32 @test2(i32 %A) {
|
|
|
|
call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A )
|
|
|
|
ret i32 %A
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-06-18 22:48:11 +00:00
|
|
|
; Resolving this should insert a cast from sbyte to int, following the C
|
|
|
|
; promotion rules.
|
2008-03-25 04:26:08 +00:00
|
|
|
declare void @test3a(i8, ...)
|
|
|
|
|
|
|
|
define void @test3(i8 %A, i8 %B) {
|
|
|
|
call void bitcast (void (i8, ...)* @test3a to void (i8, i8)*)( i8 %A, i8 %B
|
|
|
|
)
|
2003-06-18 22:48:11 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
|
2003-06-18 22:48:11 +00:00
|
|
|
; test conversion of return value...
|
2008-03-25 04:26:08 +00:00
|
|
|
define i8 @test4a() {
|
|
|
|
ret i8 0
|
|
|
|
}
|
|
|
|
|
|
|
|
define i32 @test4() {
|
|
|
|
%X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; <i32> [#uses=1]
|
|
|
|
ret i32 %X
|
2003-06-18 22:48:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
|
2003-06-18 22:48:11 +00:00
|
|
|
; test conversion of return value... no value conversion occurs so we can do
|
|
|
|
; this with just a prototype...
|
2008-03-25 04:26:08 +00:00
|
|
|
declare i32 @test5a()
|
|
|
|
|
|
|
|
define i32 @test5() {
|
|
|
|
%X = call i32 @test5a( ) ; <i32> [#uses=1]
|
|
|
|
ret i32 %X
|
2003-06-18 22:48:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
|
2003-06-18 22:48:11 +00:00
|
|
|
; test addition of new arguments...
|
2008-03-25 04:26:08 +00:00
|
|
|
declare i32 @test6a(i32)
|
|
|
|
|
|
|
|
define i32 @test6() {
|
|
|
|
%X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( ) ; <i32> [#uses=1]
|
|
|
|
ret i32 %X
|
2003-06-18 22:48:11 +00:00
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
|
2003-06-18 22:48:11 +00:00
|
|
|
; test removal of arguments, only can happen with a function body
|
2008-03-25 04:26:08 +00:00
|
|
|
define void @test7a() {
|
2003-06-18 22:48:11 +00:00
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
2008-03-25 04:26:08 +00:00
|
|
|
define void @test7() {
|
|
|
|
call void bitcast (void ()* @test7a to void (i32)*)( i32 5 )
|
|
|
|
ret void
|
|
|
|
}
|
|
|
|
|
|
|
|
|