1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-22 18:54:02 +01:00
llvm-mirror/test/CodeGen/AArch64/tailcall-bitcast-memcpy.ll
Sanne Wouda 5880a26c60 Fix missing memcpy, memmove and memset tail calls
Summary:
If a wrapper around one of the mem* stdlib functions bitcasts the returned
pointer value before returning it (e.g. to a wchar_t*), LLVM does not emit a
tail call.

Add a check for this scenario so that we emit a tail call.

Reviewers: wmi, mkuper, ramred01, dmgreen

Reviewed By: wmi, dmgreen

Subscribers: hiraditya, sanwou01, javed.absar, lebedev.ri, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D59078
2019-10-31 16:13:29 +00:00

19 lines
587 B
LLVM

;RUN: llc %s -o - -verify-machineinstrs | FileCheck %s
target triple = "aarch64-arm-none-eabi"
;CHECK-LABEL: @wmemcpy
;CHECK: lsl
;CHECK-NOT: bl
;CHECK-NOT: mov
;CHECK-NOT: ldp
;CHECK-NEXT: b memcpy
define dso_local i32* @wmemcpy(i32* returned, i32* nocapture readonly, i64) local_unnamed_addr {
%4 = bitcast i32* %0 to i8*
%5 = bitcast i32* %1 to i8*
%6 = shl i64 %2, 2
tail call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 4 %4, i8* align 4 %5, i64 %6, i1 false)
ret i32* %0
}
declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i1)