|
| 1 | +; RUN: llc -mtriple arm64-apple-darwin -asm-verbose=false -o - %s | FileCheck --check-prefix=CHECK-DAG-ISEL --check-prefix=CHECK %s |
| 2 | +; RUN: llc -mtriple arm64-apple-darwin -fast-isel -asm-verbose=false -o - %s | FileCheck --check-prefix=CHECK-FAST-ISEL --check-prefix=CHECK %s |
| 3 | + |
| 4 | +; CHECK-LABEL: _test_musttail: |
| 5 | +; CHECK: b _musttail_callee |
| 6 | + |
| 7 | +declare i32 @musttail_callee(i32) |
| 8 | + |
| 9 | +define i32 @test_musttail(i32 %arg0) { |
| 10 | + %r = musttail call i32 @musttail_callee(i32 %arg0) |
| 11 | + ret i32 %r |
| 12 | +} |
| 13 | + |
| 14 | +; CHECK-LABEL: _test_musttail_variadic: |
| 15 | +; CHECK: b _musttail_variadic_callee |
| 16 | + |
| 17 | +declare i32 @musttail_variadic_callee(i32, ...) |
| 18 | + |
| 19 | +define i32 @test_musttail_variadic(i32 %arg0, ...) { |
| 20 | + %r = musttail call i32 (i32, ...) @musttail_variadic_callee(i32 %arg0, ...) |
| 21 | + ret i32 %r |
| 22 | +} |
| 23 | + |
| 24 | +; CHECK-LABEL: _test_musttail_variadic_aggret: |
| 25 | +; CHECK: b _musttail_variadic_aggret_callee |
| 26 | + |
| 27 | +declare [2 x i64] @musttail_variadic_aggret_callee(i32 %arg0, ...) |
| 28 | + |
| 29 | +define [2 x i64] @test_musttail_variadic_aggret(i32 %arg0, ...) { |
| 30 | + %r = musttail call [2 x i64] (i32, ...) @musttail_variadic_aggret_callee(i32 %arg0, ...) |
| 31 | + ret [2 x i64] %r |
| 32 | +} |
| 33 | + |
| 34 | +; CHECK-LABEL: _test_musttail_variadic_stack: |
| 35 | +; CHECK-FAST-ISEL: ldp x9, x12, [sp] |
| 36 | +; CHECK-FAST-ISEL: ldp x10, x11, [sp, #16] |
| 37 | +; CHECK-FAST-ISEL: stp x9, x12, [sp, #16] |
| 38 | +; CHECK-FAST-ISEL: stp x10, x11, [sp] |
| 39 | +; CHECK-DAG-ISEL: ldp x9, x10, [sp] |
| 40 | +; CHECK-DAG-ISEL: ldr q16, [sp, #16] |
| 41 | +; CHECK-DAG-ISEL: str q16, [sp] |
| 42 | +; CHECK-DAG-ISEL: stp x9, x10, [sp, #16] |
| 43 | +; CHECK: b _musttail_variadic_stack_callee |
| 44 | + |
| 45 | +declare i32 @musttail_variadic_stack_callee([2 x i64] %a0, [2 x i64] %a1, [2 x i64] %a2, [2 x i64] %a3, [2 x i64] %a4, [2 x i64] %a5, ...) |
| 46 | + |
| 47 | +define i32 @test_musttail_variadic_stack([2 x i64] %a0, [2 x i64] %a1, [2 x i64] %a2, [2 x i64] %a3, [2 x i64] %a4, [2 x i64] %a5, ...) { |
| 48 | + %r = musttail call i32 ([2 x i64], [2 x i64], [2 x i64], [2 x i64], [2 x i64], [2 x i64], ...) @musttail_variadic_stack_callee([2 x i64] %a0, [2 x i64] %a1, [2 x i64] %a2, [2 x i64] %a3, [2 x i64] %a5, [2 x i64] %a4, ...) |
| 49 | + ret i32 %r |
| 50 | +} |
| 51 | + |
| 52 | +; We still mis-compile this test case because %arg2 is written to its argument |
| 53 | +; slot before %arg1 is read from its slot. |
| 54 | +; |
| 55 | +; ldr q16, [sp, #16] # read %arg2 |
| 56 | +; str q16, [sp] # write %arg2. this overwrites %arg1. |
| 57 | +; ldr q16, [sp] # read %arg1 |
| 58 | +; str q16, [sp, #16] # write %arg1 |
| 59 | +; b _musttail_variadic_byval_callee |
| 60 | + |
| 61 | +%Struct = type { i64, i64 } |
| 62 | + |
| 63 | +declare i32 @musttail_variadic_byval_callee(i32, %Struct* byval(%Struct), %Struct* byval(%Struct), ...) |
| 64 | + |
| 65 | +define i32 @test_musttail_variadic_byval(i32 %arg0, %Struct* byval(%Struct) %arg1, %Struct* byval(%Struct) %arg2, ...) { |
| 66 | + %r = musttail call i32 (i32, %Struct*, %Struct*, ...) @musttail_variadic_byval_callee(i32 %arg0, %Struct* byval(%Struct) %arg2, %Struct* byval(%Struct) %arg1, ...) |
| 67 | + ret i32 %r |
| 68 | +} |
0 commit comments