brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · c74bfb9 Raw
107 lines · plain
1; RUN: llc < %s -mtriple arm64-apple-darwin -aarch64-enable-ldst-opt=false -asm-verbose=false -disable-post-ra | FileCheck %s2; Disable the load/store optimizer to avoid having LDP/STPs and simplify checks.3 4target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"5 6; Check that we don't try to tail-call with a non-forwarded sret parameter.7declare void @test_explicit_sret(ptr sret(i1024)) #08 9; This is the only OK case, where we forward the explicit sret pointer.10 11; CHECK-LABEL: _test_tailcall_explicit_sret:12; CHECK-NEXT: b _test_explicit_sret13define void @test_tailcall_explicit_sret(ptr sret(i1024) %arg) #0 {14  tail call void @test_explicit_sret(ptr sret(i1024) %arg)15  ret void16}17 18; CHECK-LABEL: _test_call_explicit_sret:19; CHECK-NOT: mov  x820; CHECK: bl _test_explicit_sret21; CHECK: ret22define void @test_call_explicit_sret(ptr sret(i1024) %arg) #0 {23  call void @test_explicit_sret(ptr sret(i1024) %arg)24  ret void25}26 27; CHECK-LABEL: _test_tailcall_explicit_sret_alloca_unused:28; CHECK: mov  x8, sp29; CHECK-NEXT: bl _test_explicit_sret30; CHECK: ret31define void @test_tailcall_explicit_sret_alloca_unused() #0 {32  %l = alloca i1024, align 833  tail call void @test_explicit_sret(ptr sret(i1024) %l)34  ret void35}36 37; CHECK-LABEL: _test_tailcall_explicit_sret_alloca_dummyusers:38; CHECK: ldr [[PTRLOAD1:q[0-9]+]], [x0]39; CHECK: str [[PTRLOAD1]], [sp]40; CHECK: mov  x8, sp41; CHECK-NEXT: bl _test_explicit_sret42; CHECK: ret43define void @test_tailcall_explicit_sret_alloca_dummyusers(ptr %ptr) #0 {44  %l = alloca i1024, align 845  %r = load i1024, ptr %ptr, align 846  store i1024 %r, ptr %l, align 847  tail call void @test_explicit_sret(ptr sret(i1024) %l)48  ret void49}50 51; This is too conservative, but doesn't really happen in practice.52 53; CHECK-LABEL: _test_tailcall_explicit_sret_gep:54; CHECK: add  x8, x0, #12855; CHECK-NEXT: bl _test_explicit_sret56; CHECK: ret57define void @test_tailcall_explicit_sret_gep(ptr %ptr) #0 {58  %ptr2 = getelementptr i1024, ptr %ptr, i32 159  tail call void @test_explicit_sret(ptr sret(i1024) %ptr2)60  ret void61}62 63; CHECK-LABEL: _test_tailcall_explicit_sret_alloca_returned:64; CHECK: mov  x[[CALLERX8NUM:[0-9]+]], x865; CHECK: mov  x8, sp66; CHECK-NEXT: bl _test_explicit_sret67; CHECK-NEXT: ldr [[CALLERSRET1:q[0-9]+]], [sp]68; CHECK: str [[CALLERSRET1:q[0-9]+]], [x[[CALLERX8NUM]]]69; CHECK: ret70define i1024 @test_tailcall_explicit_sret_alloca_returned() #0 {71  %l = alloca i1024, align 872  tail call void @test_explicit_sret(ptr sret(i1024) %l)73  %r = load i1024, ptr %l, align 874  ret i1024 %r75}76 77; CHECK-LABEL: _test_indirect_tailcall_explicit_sret_nosret_arg:78; CHECK-DAG: mov  x[[CALLERX8NUM:[0-9]+]], x879; CHECK-DAG: mov  [[FPTR:x[0-9]+]], x080; CHECK: mov  x0, sp81; CHECK-NEXT: blr [[FPTR]]82; CHECK: ldr [[CALLERSRET1:q[0-9]+]], [sp]83; CHECK: str [[CALLERSRET1:q[0-9]+]], [x[[CALLERX8NUM]]]84; CHECK: ret85define void @test_indirect_tailcall_explicit_sret_nosret_arg(ptr sret(i1024) %arg, ptr %f) #0 {86  %l = alloca i1024, align 887  tail call void %f(ptr %l)88  %r = load i1024, ptr %l, align 889  store i1024 %r, ptr %arg, align 890  ret void91}92 93; CHECK-LABEL: _test_indirect_tailcall_explicit_sret_:94; CHECK: mov  x[[CALLERX8NUM:[0-9]+]], x895; CHECK: mov  x8, sp96; CHECK-NEXT: blr x097; CHECK: ldr [[CALLERSRET1:q[0-9]+]], [sp]98; CHECK: str [[CALLERSRET1:q[0-9]+]], [x[[CALLERX8NUM]]]99; CHECK: ret100define void @test_indirect_tailcall_explicit_sret_(ptr sret(i1024) %arg, ptr %f) #0 {101  %ret = tail call i1024 %f()102  store i1024 %ret, ptr %arg, align 8103  ret void104}105 106attributes #0 = { nounwind }107