This is an archive of the discontinued LLVM Phabricator instance.

[TailCall] Allow llvm.memcpy/memset/memmove to be tail calls when parent function return the intrinsics's first argument
ClosedPublic

Authored by wmi on Sep 1 2017, 4:53 PM.

Details

Summary

llvm.memcpy/memset/memmove return void but they will return the first argument after they are expanded as libcalls. Now if the parent function has any return value, llvm.memcpy cannot be turned into tail call after expansion.

The patch is to handle that case in SelectionDAGBuilder so when caller function return the same value as the first argument of llvm.memcpy, tail call is allowed.

Diff Detail

Repository
rL LLVM

Event Timeline

wmi created this revision.Sep 1 2017, 4:53 PM
kparzysz accepted this revision.Sep 5 2017, 12:23 PM
This revision is now accepted and ready to land.Sep 5 2017, 12:23 PM
This revision was automatically updated to reflect the committed changes.
efriedma added inline comments.
llvm/trunk/lib/CodeGen/Analysis.cpp
569

This is only true if the argument is specifically expanded to a libcall to the C library function "memcpy". If the target expands it to some other library call (e.g., __aeabi_memcpy, like we do on Android), it isn't a tail call, and we miscompile.