OLD | NEW |
(Empty) | |
| 1 ; RUN: opt < %s -expand-varargs -S | FileCheck %s |
| 2 |
| 3 declare i32 @varargs_func(i32 %arg, ...) |
| 4 |
| 5 |
| 6 ; Check that attributes such as "byval" are preserved on fixed arguments. |
| 7 |
| 8 %MyStruct = type { i64, i64 } |
| 9 |
| 10 define void @func_with_arg_attrs(%MyStruct* byval, ...) { |
| 11 ret void |
| 12 } |
| 13 ; CHECK: define void @func_with_arg_attrs(%MyStruct* byval, i8* noalias %varargs
) { |
| 14 |
| 15 |
| 16 declare void @take_struct_arg(%MyStruct* byval %s, ...) |
| 17 |
| 18 define void @call_with_arg_attrs(%MyStruct* %s) { |
| 19 call void (%MyStruct*, ...)* @take_struct_arg(%MyStruct* byval %s) |
| 20 ret void |
| 21 } |
| 22 ; CHECK: define void @call_with_arg_attrs(%MyStruct* %s) { |
| 23 ; CHECK: call void %vararg_func(%MyStruct* byval %s, <{ i32 }>* %vararg_buffer) |
| 24 |
| 25 |
| 26 ; The "byval" attribute here should be dropped. |
| 27 define i32 @pass_struct_via_vararg1(%MyStruct* %s) { |
| 28 %result = call i32 (i32, ...)* @varargs_func(i32 111, %MyStruct* byval %s) |
| 29 ret i32 %result |
| 30 } |
| 31 ; CHECK: define i32 @pass_struct_via_vararg1(%MyStruct* %s) { |
| 32 ; CHECK: %result = call i32 %vararg_func(i32 111, <{ %MyStruct }>* %vararg_buffe
r) |
| 33 |
| 34 |
| 35 ; The "byval" attribute here should be dropped. |
| 36 define i32 @pass_struct_via_vararg2(%MyStruct* %s) { |
| 37 %result = call i32 (i32, ...)* @varargs_func(i32 111, i32 2, %MyStruct* byval
%s) |
| 38 ret i32 %result |
| 39 } |
| 40 ; CHECK: define i32 @pass_struct_via_vararg2(%MyStruct* %s) { |
| 41 ; CHECK: %result = call i32 %vararg_func(i32 111, <{ i32, %MyStruct }>* %vararg_
buffer) |
| 42 |
| 43 |
| 44 ; Check that return attributes such as "signext" are preserved. |
| 45 define i32 @call_with_return_attr() { |
| 46 %result = call signext i32 (i32, ...)* @varargs_func(i32 111, i64 222) |
| 47 ret i32 %result |
| 48 } |
| 49 ; CHECK: define i32 @call_with_return_attr() { |
| 50 ; CHECK: %result = call signext i32 %vararg_func(i32 111 |
| 51 |
| 52 |
| 53 ; Check that the "readonly" function attribute is preserved. |
| 54 define i32 @call_readonly() { |
| 55 %result = call i32 (i32, ...)* @varargs_func(i32 111, i64 222) readonly |
| 56 ret i32 %result |
| 57 } |
| 58 ; CHECK: define i32 @call_readonly() { |
| 59 ; CHECK: %result = call i32 %vararg_func(i32 111, {{.*}}) #1 |
| 60 |
| 61 |
| 62 ; Check that the "tail" attribute gets removed, because the callee |
| 63 ; reads space alloca'd by the caller. |
| 64 define i32 @tail_call() { |
| 65 %result = tail call i32 (i32, ...)* @varargs_func(i32 111, i64 222) |
| 66 ret i32 %result |
| 67 } |
| 68 ; CHECK: define i32 @tail_call() { |
| 69 ; CHECK: %result = call i32 %vararg_func(i32 111 |
| 70 |
| 71 |
| 72 ; CHECK: attributes #1 = { readonly } |
OLD | NEW |