On Thu, Jul 28, 2011 at 2:49 PM, Richard Henderson <r...@redhat.com> wrote:
> The whole problem is that toc pointer copy in 40(1) is only valid > during indirect call sequences, and iff ld inserted a stub? I.e. > direct calls between functions that share toc pointers never save > the copy? > > Would it make sense, if a function has any indirect call, to move > the toc pointer save into the prologue? You'd get to avoid that > store all the time. Of course you'd not be able to sink the load > after the call, but it might still be a win. And in that special > case you can annotate the r2 save slot just once, correctly. Michael Meissner recently did move R2 save into the prologue, under certain circumstances. See TARGET_SAVE_TOC_INDIRECT. Limitations include alloca (unless one re-copies the R2. Mike also encountered some problems with EH, which may be related to this discussion. The other problem is hoisting the store into the prologue is not always profitable for performance. It should be better once shrink wrapping is implemented. Currently the PPC ABI may perform a lot of stores in the prologue if the function *may* make a call. R2 adds yet another store to the common path. - David