Re: [PATCH] powerpc: inline current_stack_pointer()

From: Paul Mackerras
Date: Tue May 24 2016 - 23:40:26 EST

On Mon, May 23, 2016 at 07:17:38PM +0200, Gabriel Paubert wrote:
> On Mon, May 23, 2016 at 10:46:02AM +0200, Christophe Leroy wrote:
> > current_stack_pointeur() is a single instruction function. it
> > It is not worth breaking the execution flow with a bl/blr for a
> > single instruction
> Are you sure that the result is always the same?
> Calling an external function prevents the compiler from considering the
> caller of of current_stack_pointer a leaf function, which certainly
> does not help the compiler, but in a leaf function the compiler is free
> not to establish a new frame.
> If the compiler decides to establishes a new frame (typically with
> "stwu r1,-frame_size(r1)"), *r1 is the previous stack pointer, or
> the caller's stack pointer, or the current function frame pointer if
> I remember correctly the ABI definitions.
> However, if the compiler decides that it can get away without a frame
> for the function, *r1 is the stack pointer of the caller's caller.
> Depending on the application, this may or may not be important.

Right. I think I wrote the original current_stack_pointer()
implementation, and that I deliberately didn't make it an inline
so that the caller would have to establish its own stack frame,
and thus its stack pointer value would be a well-defined thing.