brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.8 KiB · 0ff6ae2 Raw
105 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py2; RUN: llc < %s -mtriple arm64-apple-darwin -global-isel -stop-after=irtranslator -verify-machineinstrs | FileCheck %s3 4; Check that we don't try to tail-call with a non-forwarded sret parameter.5declare void @test_explicit_sret(ptr sret(i64))6 7; Forwarded explicit sret pointer => we can tail call.8define void @can_tail_call_forwarded_explicit_sret_ptr(ptr sret(i64) %arg) {9  ; CHECK-LABEL: name: can_tail_call_forwarded_explicit_sret_ptr10  ; CHECK: bb.1 (%ir-block.0):11  ; CHECK-NEXT:   liveins: $x812  ; CHECK-NEXT: {{  $}}13  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(p0) = COPY $x814  ; CHECK-NEXT:   $x8 = COPY [[COPY]](p0)15  ; CHECK-NEXT:   TCRETURNdi @test_explicit_sret, 0, csr_darwin_aarch64_aapcs, implicit $sp, implicit $x816  tail call void @test_explicit_sret(ptr %arg)17  ret void18}19 20; Not marked as tail, so don't tail call.21define void @test_call_explicit_sret(ptr sret(i64) %arg) {22  ; CHECK-LABEL: name: test_call_explicit_sret23  ; CHECK: bb.1 (%ir-block.0):24  ; CHECK-NEXT:   liveins: $x825  ; CHECK-NEXT: {{  $}}26  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(p0) = COPY $x827  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp28  ; CHECK-NEXT:   $x8 = COPY [[COPY]](p0)29  ; CHECK-NEXT:   BL @test_explicit_sret, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x830  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp31  ; CHECK-NEXT:   RET_ReallyLR32  call void @test_explicit_sret(ptr %arg)33  ret void34}35 36define void @dont_tail_call_explicit_sret_alloca_unused() {37  ; CHECK-LABEL: name: dont_tail_call_explicit_sret_alloca_unused38  ; CHECK: bb.1 (%ir-block.0):39  ; CHECK-NEXT:   [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.l40  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp41  ; CHECK-NEXT:   $x8 = COPY [[FRAME_INDEX]](p0)42  ; CHECK-NEXT:   BL @test_explicit_sret, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x843  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp44  ; CHECK-NEXT:   RET_ReallyLR45  %l = alloca i64, align 846  tail call void @test_explicit_sret(ptr %l)47  ret void48}49 50define void @dont_tail_call_explicit_sret_alloca_dummyusers(ptr %ptr) {51  ; CHECK-LABEL: name: dont_tail_call_explicit_sret_alloca_dummyusers52  ; CHECK: bb.1 (%ir-block.0):53  ; CHECK-NEXT:   liveins: $x054  ; CHECK-NEXT: {{  $}}55  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(p0) = COPY $x056  ; CHECK-NEXT:   [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.l57  ; CHECK-NEXT:   [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[COPY]](p0) :: (load (s64) from %ir.ptr)58  ; CHECK-NEXT:   G_STORE [[LOAD]](s64), [[FRAME_INDEX]](p0) :: (store (s64) into %ir.l)59  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp60  ; CHECK-NEXT:   $x8 = COPY [[FRAME_INDEX]](p0)61  ; CHECK-NEXT:   BL @test_explicit_sret, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x862  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp63  ; CHECK-NEXT:   RET_ReallyLR64  %l = alloca i64, align 865  %r = load i64, ptr %ptr, align 866  store i64 %r, ptr %l, align 867  tail call void @test_explicit_sret(ptr %l)68  ret void69}70 71define void @dont_tail_call_tailcall_explicit_sret_gep(ptr %ptr) {72  ; CHECK-LABEL: name: dont_tail_call_tailcall_explicit_sret_gep73  ; CHECK: bb.1 (%ir-block.0):74  ; CHECK-NEXT:   liveins: $x075  ; CHECK-NEXT: {{  $}}76  ; CHECK-NEXT:   [[COPY:%[0-9]+]]:_(p0) = COPY $x077  ; CHECK-NEXT:   [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 878  ; CHECK-NEXT:   [[PTR_ADD:%[0-9]+]]:_(p0) = G_PTR_ADD [[COPY]], [[C]](s64)79  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp80  ; CHECK-NEXT:   $x8 = COPY [[PTR_ADD]](p0)81  ; CHECK-NEXT:   BL @test_explicit_sret, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x882  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp83  ; CHECK-NEXT:   RET_ReallyLR84  %ptr2 = getelementptr i64, ptr %ptr, i32 185  tail call void @test_explicit_sret(ptr %ptr2)86  ret void87}88 89define i64 @dont_tail_call_sret_alloca_returned() {90  ; CHECK-LABEL: name: dont_tail_call_sret_alloca_returned91  ; CHECK: bb.1 (%ir-block.0):92  ; CHECK-NEXT:   [[FRAME_INDEX:%[0-9]+]]:_(p0) = G_FRAME_INDEX %stack.0.l93  ; CHECK-NEXT:   ADJCALLSTACKDOWN 0, 0, implicit-def $sp, implicit $sp94  ; CHECK-NEXT:   $x8 = COPY [[FRAME_INDEX]](p0)95  ; CHECK-NEXT:   BL @test_explicit_sret, csr_darwin_aarch64_aapcs, implicit-def $lr, implicit $sp, implicit $x896  ; CHECK-NEXT:   ADJCALLSTACKUP 0, 0, implicit-def $sp, implicit $sp97  ; CHECK-NEXT:   [[LOAD:%[0-9]+]]:_(s64) = G_LOAD [[FRAME_INDEX]](p0) :: (dereferenceable load (s64) from %ir.l)98  ; CHECK-NEXT:   $x0 = COPY [[LOAD]](s64)99  ; CHECK-NEXT:   RET_ReallyLR implicit $x0100  %l = alloca i64, align 8101  tail call void @test_explicit_sret(ptr %l)102  %r = load i64, ptr %l, align 8103  ret i64 %r104}105