This is an archive of the discontinued LLVM Phabricator instance.

Allow memory intrinsics to be tail calls
ClosedPublic

Authored by kparzysz on Apr 2 2015, 1:24 PM.

Details

Summary

If the target lowering decides to create a call from a memory intrinsic (memcpy, memmove or memset), the call will not become a tail call even if it is possible.
This patch enables such conversion.

Diff Detail

Repository
rL LLVM

Event Timeline

kparzysz updated this revision to Diff 23178.Apr 2 2015, 1:24 PM
kparzysz retitled this revision from to Allow memory intrinsics to be tail calls.
kparzysz updated this object.
kparzysz edited the test plan for this revision. (Show Details)
kparzysz added a reviewer: resistor.
kparzysz set the repository for this revision to rL LLVM.
kparzysz added a subscriber: Unknown Object (MLST).

Hi Duncan. Owen seems to be MIA and you've been making changes to the SDAG code recently. Could you review?

mcrosier edited reviewers, added: rnk, silvas; removed: dexonsmith.Apr 10 2015, 11:49 AM
resistor added inline comments.Apr 13 2015, 12:30 AM
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
4598

This code sequence is repeated in a few places. Could it be extracted (and commented)?

kparzysz updated this revision to Diff 23682.Apr 13 2015, 10:08 AM

Extracted the DAG/DAG builder update into a separate function.

resistor accepted this revision.Apr 13 2015, 10:10 AM
resistor edited edge metadata.

LGTM.

This revision is now accepted and ready to land.Apr 13 2015, 10:10 AM
kparzysz closed this revision.Apr 13 2015, 10:22 AM

Commited in r234764.

This is causing test failures for me, because it's jumping to _memset rather than memset (host platform is OS X). Probably needs an appropriate triple set.

/Users/kfischer/Projects/llvm2/test/CodeGen/X86/tailcall-mem-intrinsics.ll:20:10: error: expected string not found in input
; CHECK: jmp memset
         ^
<stdin>:17:13: note: scanning from here
_tail_memset: ## @tail_memset
            ^
<stdin>:19:2: note: possible intended match here
 jmp _memset ## TAILCALL

Does -mtriple=x86_64-pc-linux-gnu work for you?
-K

Yes, that does fix it.

Fixed the x86 testcase in r234793.

Sorry, I should have mentioned that the same problem occurs with AArch64 as
well, but adding -mtriple=aarch64-pc-linux-gnu fixes it.

2015-04-13 16:28 GMT-04:00 Krzysztof Parzyszek <kparzysz@codeaurora.org>:

Fixed the x86 testcase in r234793.

REPOSITORY

rL LLVM

http://reviews.llvm.org/D8808

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/