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]

Re: Const/libcall function calling tweeks


> On Tue, Mar 07, 2000 at 03:07:08PM +0100, Jan Hubicka wrote:
> > The expand_call calls NO_DEFER_POP for the const functions. 
> > I don't see any purpose for doing that, since this only affects
> > the nested function calls in the arguments.
> 
> Err.. It shouldn't.  What's is intended is that the bits in between
> the REG_LIBCALL and the REG_RETVAL be self-contained.  If we don't
> turn on NO_DEFER_POP, the stack adjustment will be dependant on the
> context of the surrounding calls.
Oops?
Do you have something like this in the mind?:
int a(int, int) __attribute__ ((const));
main()
{
  return a(b(1),b(1));
}
The code generated is:
main:
        pushl %ebp
        movl %esp,%ebp
        pushl %ebx
        pushl $1
        call b
        addl $4,%esp  (*)
        movl %eax,%ebx
        pushl $1
        call b
        addl $4,%esp  (*)
        pushl %ebx
        pushl %eax
        call a
        movl -4(%ebp),%ebx
        leave
(this is done by old egcs, but I expect it is still the same).
The calls to be are not nested into calls to a, so everything is OK/.
The calling code to b is outside the notes.
The NO_DEFER_POP in question IMO have only effect, that adds unnecesary
stack adjustment marked by the asterisk.
The code will be still valid (IE code in the notes self contained) if
inhibit_defer_pop was 0 for b calls.
Emit_call_1 takes case to not use pending_stack_adjust for const
calls.

> 

> Of course, I'm quite certain we also get this wrong for stack 
> alignment to nested calls.  Yep, just tested it.
What case do you have in the mind?
(I am trying to collect all known such problems)
> 
> All this is quite ugly.  I'm wondering if it wouldn't be simpler to
> just give up and un-nest calls before expansion.
I think it is quite good for keeping register lifetimes short.
Give me chance, I would like to try (I am not yet sure how) to cleanup
the code in order to make these bits maintainable.
> 
> 
> r~
Honza

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