mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 11:13:28 +01:00
3e22de98ba
Because memory intrinsics are handled differently than other calls, we need to check them for tail call eligiblity in the legalizer. This allows us to still inline them when it's beneficial to do so, but also tail call when possible. This adds simple tail calling support for when the intrinsic is followed by a return. It ports the attribute checks from `TargetLowering::isInTailCallPosition` into a similarly-named function in LegalizerHelper.cpp. The target-specific `isUsedByReturnOnly` hook is not ported here. Update tailcall-mem-intrinsics.ll to show that GlobalISel can now tail call memory intrinsics. Update legalize-memcpy-et-al.mir to have a case where we don't tail call. Differential Revision: https://reviews.llvm.org/D67566 llvm-svn: 371893
33 lines
1.1 KiB
LLVM
33 lines
1.1 KiB
LLVM
; RUN: llc -mtriple=aarch64-unknown-unknown < %s | FileCheck %s
|
|
; RUN: llc -global-isel-abort=1 -verify-machineinstrs -mtriple=aarch64-unknown-unknown -global-isel < %s | FileCheck %s
|
|
|
|
; CHECK-LABEL: tail_memcpy:
|
|
; CHECK: b memcpy
|
|
define void @tail_memcpy(i8* nocapture %p, i8* nocapture readonly %q, i32 %n) #0 {
|
|
entry:
|
|
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %p, i8* %q, i32 %n, i1 false)
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: tail_memmove:
|
|
; CHECK: b memmove
|
|
define void @tail_memmove(i8* nocapture %p, i8* nocapture readonly %q, i32 %n) #0 {
|
|
entry:
|
|
tail call void @llvm.memmove.p0i8.p0i8.i32(i8* %p, i8* %q, i32 %n, i1 false)
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: tail_memset:
|
|
; CHECK: b memset
|
|
define void @tail_memset(i8* nocapture %p, i8 %c, i32 %n) #0 {
|
|
entry:
|
|
tail call void @llvm.memset.p0i8.i32(i8* %p, i8 %c, i32 %n, i1 false)
|
|
ret void
|
|
}
|
|
|
|
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) #0
|
|
declare void @llvm.memmove.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i1) #0
|
|
declare void @llvm.memset.p0i8.i32(i8* nocapture, i8, i32, i1) #0
|
|
|
|
attributes #0 = { nounwind }
|