OLD | NEW |
---|---|
1 ; RUN: opt < %s -expand-varargs -S | FileCheck %s | 1 ; RUN: opt < %s -expand-varargs -S | FileCheck %s |
2 | 2 |
3 declare i32 @varargs_func(i32 %arg, ...) | 3 declare i32 @varargs_func(i32 %arg, ...) |
4 | 4 |
5 | 5 |
6 ; Check that attributes such as "byval" are preserved on fixed arguments. | 6 ; Check that attributes such as "byval" are preserved on fixed arguments. |
7 | 7 |
8 %MyStruct = type { i64, i64 } | 8 %MyStruct = type { i64, i64 } |
9 | 9 |
10 define void @func_with_arg_attrs(%MyStruct* byval, ...) { | 10 define void @func_with_arg_attrs(%MyStruct* byval, ...) { |
11 ret void | 11 ret void |
12 } | 12 } |
13 ; CHECK: define void @func_with_arg_attrs(%MyStruct* byval, i8* %varargs) { | 13 ; CHECK: define void @func_with_arg_attrs(%MyStruct* byval, i8* %varargs) { |
jvoung (off chromium)
2013/04/26 16:43:09
Should this new definition have noalias for the %v
Mark Seaborn
2013/04/26 16:52:58
Oops, yes, I wasn't thinking. "noalias" should go
| |
14 | 14 |
15 | 15 |
16 declare void @take_struct_arg(%MyStruct* byval %s, ...) | 16 declare void @take_struct_arg(%MyStruct* byval %s, ...) |
17 | 17 |
18 define void @call_with_arg_attrs(%MyStruct* %s) { | 18 define void @call_with_arg_attrs(%MyStruct* %s) { |
19 call void (%MyStruct*, ...)* @take_struct_arg(%MyStruct* byval %s) | 19 call void (%MyStruct*, ...)* @take_struct_arg(%MyStruct* byval %s) |
20 ret void | 20 ret void |
21 } | 21 } |
22 ; CHECK: define void @call_with_arg_attrs(%MyStruct* %s) { | 22 ; CHECK: define void @call_with_arg_attrs(%MyStruct* %s) { |
23 ; CHECK: call void %vararg_func(%MyStruct* byval %s, %vararg_call{{.*}} %vararg_ buffer) | 23 ; CHECK: call void %vararg_func(%MyStruct* byval %s, %vararg_call{{.*}} noalias %vararg_buffer) |
24 | 24 |
25 | 25 |
26 ; The "byval" attribute here should be dropped. | 26 ; The "byval" attribute here should be dropped. |
27 define i32 @pass_struct_via_vararg1(%MyStruct* %s) { | 27 define i32 @pass_struct_via_vararg1(%MyStruct* %s) { |
28 %result = call i32 (i32, ...)* @varargs_func(i32 111, %MyStruct* byval %s) | 28 %result = call i32 (i32, ...)* @varargs_func(i32 111, %MyStruct* byval %s) |
29 ret i32 %result | 29 ret i32 %result |
30 } | 30 } |
31 ; CHECK: define i32 @pass_struct_via_vararg1(%MyStruct* %s) { | 31 ; CHECK: define i32 @pass_struct_via_vararg1(%MyStruct* %s) { |
32 ; CHECK: %result = call i32 %vararg_func(i32 111, %{{.*}}* %vararg_buffer) | 32 ; CHECK: %result = call i32 %vararg_func(i32 111, %{{.*}}* noalias %vararg_buffe r) |
33 | 33 |
34 | 34 |
35 ; The "byval" attribute here should be dropped. | 35 ; The "byval" attribute here should be dropped. |
36 define i32 @pass_struct_via_vararg2(%MyStruct* %s) { | 36 define i32 @pass_struct_via_vararg2(%MyStruct* %s) { |
37 %result = call i32 (i32, ...)* @varargs_func(i32 111, i32 2, %MyStruct* byval %s) | 37 %result = call i32 (i32, ...)* @varargs_func(i32 111, i32 2, %MyStruct* byval %s) |
38 ret i32 %result | 38 ret i32 %result |
39 } | 39 } |
40 ; CHECK: define i32 @pass_struct_via_vararg2(%MyStruct* %s) { | 40 ; CHECK: define i32 @pass_struct_via_vararg2(%MyStruct* %s) { |
41 ; CHECK: %result = call i32 %vararg_func(i32 111, %{{.*}}* %vararg_buffer) | 41 ; CHECK: %result = call i32 %vararg_func(i32 111, %{{.*}}* noalias %vararg_buffe r) |
42 | 42 |
43 | 43 |
44 ; Check that return attributes such as "signext" are preserved. | 44 ; Check that return attributes such as "signext" are preserved. |
45 define i32 @call_with_return_attr() { | 45 define i32 @call_with_return_attr() { |
46 %result = call signext i32 (i32, ...)* @varargs_func(i32 111, i64 222) | 46 %result = call signext i32 (i32, ...)* @varargs_func(i32 111, i64 222) |
47 ret i32 %result | 47 ret i32 %result |
48 } | 48 } |
49 ; CHECK: define i32 @call_with_return_attr() { | 49 ; CHECK: define i32 @call_with_return_attr() { |
50 ; CHECK: %result = call signext i32 %vararg_func(i32 111 | 50 ; CHECK: %result = call signext i32 %vararg_func(i32 111 |
51 | 51 |
(...skipping 11 matching lines...) Expand all Loading... | |
63 ; reads space alloca'd by the caller. | 63 ; reads space alloca'd by the caller. |
64 define i32 @tail_call() { | 64 define i32 @tail_call() { |
65 %result = tail call i32 (i32, ...)* @varargs_func(i32 111, i64 222) | 65 %result = tail call i32 (i32, ...)* @varargs_func(i32 111, i64 222) |
66 ret i32 %result | 66 ret i32 %result |
67 } | 67 } |
68 ; CHECK: define i32 @tail_call() { | 68 ; CHECK: define i32 @tail_call() { |
69 ; CHECK: %result = call i32 %vararg_func(i32 111 | 69 ; CHECK: %result = call i32 %vararg_func(i32 111 |
70 | 70 |
71 | 71 |
72 ; CHECK: attributes #1 = { readonly } | 72 ; CHECK: attributes #1 = { readonly } |
OLD | NEW |