[PATCH] D33562: MachineLICM: Add new condition for hoisting of caller preserved registers

Sean Fertile via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 30 10:41:39 PDT 2017


sfertile added a comment.

In https://reviews.llvm.org/D33562#767893, @iteratee wrote:

> In https://reviews.llvm.org/D33562#766989, @nemanjai wrote:
>
> > > You talk about a call instruction? Is X2 saved and restored in the called function? Then it's just a CSR and should not be mentioned in the clobber list so no problem with my proposal above.
> >
> > But it is the caller that saves and restores it, not the callee. The sequence is essentially this (all in the caller of course):
> >
> > - Save X2 to it's stack slot
> > - Update X2 prior to the call
> > - Call the function through a pointer
> > - Restore X2 immediately after the call
>
>
> But all of that occurs via the linker.
>  X2 is saved by a trampoline if necessary, and restored in the nop slot if necessary.
>  As far as the surrounding code is concerned, the trampoline is the callee, (the nop slot may be considered part of the trampoline.)
>  Treating X2 as callee saved makes perfect sense as far as llvm is concerned.


For a normal call the linker inserts the save and restore. When calling through a function pointer the compiler inserts the save/restore of the TOC pointer, and that  is what is causing the address calculations not to get hoisted.


https://reviews.llvm.org/D33562





More information about the llvm-commits mailing list