diff options
Diffstat (limited to 'test/Transforms/InstCombine/call.ll')
-rw-r--r-- | test/Transforms/InstCombine/call.ll | 73 |
1 files changed, 46 insertions, 27 deletions
diff --git a/test/Transforms/InstCombine/call.ll b/test/Transforms/InstCombine/call.ll index 1570165..9f9a280 100644 --- a/test/Transforms/InstCombine/call.ll +++ b/test/Transforms/InstCombine/call.ll @@ -1,58 +1,77 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -instcombine | llvm-dis | \ +; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ ; RUN: grep call | notcast ; END. -implementation ; Simple case, argument translatable without changing the value -declare void %test1a(sbyte *%A) -void %test1(int *%A) { - call void(int*)* cast (void(sbyte*)* %test1a to void(int*)*)(int* %A) +declare void @test1a(i8*) + +define void @test1(i32* %A) { + call void bitcast (void (i8*)* @test1a to void (i32*)*)( i32* %A ) ret void } ; More complex case, translate argument because of resolution. This is safe ; because we have the body of the function -void %test2a(sbyte %A) { ret void } -int %test2(int %A) { - call void(int)* cast (void(sbyte)* %test2a to void(int)*)(int %A) - ret int %A +define void @test2a(i8 %A) { + ret void } +define i32 @test2(i32 %A) { + call void bitcast (void (i8)* @test2a to void (i32)*)( i32 %A ) + ret i32 %A +} + + ; Resolving this should insert a cast from sbyte to int, following the C ; promotion rules. -declare void %test3a(sbyte %A, ...) -void %test3(sbyte %A, sbyte %B) { - call void(sbyte, sbyte)* cast (void(sbyte,...)* %test3a to void(sbyte,sbyte)*)(sbyte %A, sbyte %B) +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 +) ret void } + ; test conversion of return value... -sbyte %test4a() { ret sbyte 0 } -int %test4() { - %X = call int()* cast (sbyte()* %test4a to int()*)() - ret int %X +define i8 @test4a() { + ret i8 0 +} + +define i32 @test4() { + %X = call i32 bitcast (i8 ()* @test4a to i32 ()*)( ) ; <i32> [#uses=1] + ret i32 %X } + ; test conversion of return value... no value conversion occurs so we can do ; this with just a prototype... -declare uint %test5a() -int %test5() { - %X = call int()* cast (uint()* %test5a to int()*)() - ret int %X +declare i32 @test5a() + +define i32 @test5() { + %X = call i32 @test5a( ) ; <i32> [#uses=1] + ret i32 %X } + ; test addition of new arguments... -declare int %test6a(int %X) -int %test6() { - %X = call int()* cast (int(int)* %test6a to int()*)() - ret int %X +declare i32 @test6a(i32) + +define i32 @test6() { + %X = call i32 bitcast (i32 (i32)* @test6a to i32 ()*)( ) ; <i32> [#uses=1] + ret i32 %X } + ; test removal of arguments, only can happen with a function body -void %test7a() { ret void } -void %test7() { - call void(int)* cast (void()* %test7a to void(int)*)(int 5) +define void @test7a() { ret void } +define void @test7() { + call void bitcast (void ()* @test7a to void (i32)*)( i32 5 ) + ret void +} + + |