This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 4/6]: Ping: Merge from Stack Branch - i386 backend changes


On Mon, May 5, 2008 at 9:25 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Mon, May 5, 2008 at 8:12 PM, H.J. Lu <hjl.tools@gmail.com> wrote:
>  >
>  > On Mon, May 5, 2008 at 5:57 PM, Ye, Joey <joey.ye@intel.com> wrote:
>  >  > Jan,
>  >  >
>  >  > > You can certainly track this with callgraph.  I.e. use case 0 by
>  >  >  > default, but case 2 if you know bar is being called only from foos
>  >  >  that
>  >  >  > will align anyway.
>  >  >  > Since we compile in topological order, it all depends on how well you
>  >  >  > are able to decide on alignments at tree level or if you want to go
>  >  >  down
>  >  >  > the road of alternate entry point (so foo can skip alignment prologue
>  >  >  if
>  >  >  > called from function with proper alignment guaranteed).
>  >  >  How about bar is called from other compilation units? Call callgraph
>  >  >  track that?
>  >  >
>  >
>  >  As far as I can tell, preferred_incoming_stack_boundary tracked by callgraph
>  >  is a best effort approach. There is no guarantee that all callers will satisfy
>  >  preferred_incoming_stack_boundary needed by callee. If callee needs strict
>  >  alignment, it has to align the stack itself.
>  >
>  >  With automatic stack alignment, we don't need to collect
>  >  preferred_incoming_stack_boundary
>  >  in callgraph.  Without automatic stack alignment, we align outgoing stack
>  >  to PREFERRED_STACK_BOUNDARY, no more and no less. If
>  >  preferred_incoming_stack_boundary > PREFERRED_STACK_BOUNDARY,
>  >  we still can't align outgoing stack to preferred_incoming_stack_boundary.
>  >
>
>  Hi Joey,
>
>  If we know all incoming stack alignments of functions we call, can we optimize
>  stack for caller? That is for
>
>  foo ()
>  {
>   bar1 ();
>  ...
>   bar2 ();
>  }
>
>  the required stack boundary of foo will be
>
>  MAX (LOCAL, MIN (PREFERRED, MAX (INCOMING (bar1), INCOMING (bar2))))
>
>  We may be able to use less stack in foo if the required stack boundary
>  is smaller.
>  But it won't affect stack alignment in foo since we won't align
>  outgoing stack beyond
>  PREFERRED unless we need to put something on stack.
>

Hi Joey,

We don't care about if the caller is a leaf function or not. As long
as we know stack alignments of all callees, we can optimize
stack usage.


H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]