Discussion:
question about -mpush-args -maccumulate-outgoing-args on gcc for x86
Godmar Back
2009-09-01 14:08:31 UTC
Permalink
Hi,

I'm using gcc version 4.1.2 20080704 (Red Hat 4.1.2-44) for a x86
target. The info page says:

`-mpush-args'
`-mno-push-args'
Use PUSH operations to store outgoing parameters. This method is
shorter and usually equally fast as method using SUB/MOV
operations and is enabled by default. In some cases disabling it
may improve performance because of improved scheduling and reduced
dependencies.

`-maccumulate-outgoing-args'
If enabled, the maximum amount of space required for outgoing
arguments will be computed in the function prologue. This is
faster on most modern CPUs because of reduced dependencies,
improved scheduling and reduced stack usage when preferred stack
boundary is not equal to 2. The drawback is a notable increase in
code size. This switch implies `-mno-push-args'.

This information is also found on
http://gcc.gnu.org/onlinedocs/gcc/i386-and-x86_002d64-Options.html
----------------

Is this information up-to-date?

It appears to me that '-mno-push-args' is the enabled by default (*),
and not '-mpush-args'. Moreover, since -maccumulate-outgoing-args
implies -mno-push-args, it appears that the only way to obtain
'push-args' behavior is to specify '-mno-accumulate-outgoing-args' - a
switch which the documentation doesn't even mention.

I have searched the mailing list archives and the only post I found
was this one:
http://gcc.gnu.org/ml/gcc/2005-01/msg00761.html which is at odds with
the documentation above.

Thanks.

- Godmar

(*) for instance, see:

***@setzer [39](~/tmp) > cat call.c
void caller(void) {
extern void callee(int);
callee(5);
}
***@setzer [40](~/tmp) > gcc -mno-push-args -S call.c
***@setzer [41](~/tmp) > cat call.s
.file "call.c"
.text
.globl caller
.type caller, @function
caller:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl $5, (%esp)
call callee
leave
ret
.size caller, .-caller
.ident "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-44)"
.section .note.GNU-stack,"",@progbits
Godmar Back
2009-09-01 15:08:00 UTC
Permalink
Post by Godmar Back
void caller(void) {
   extern void callee(int);
   callee(5);
}
should be '-mpush-args' as in:

***@cyan [4](~/tmp) > gcc -S -mpush-args call.c
***@cyan [5](~/tmp) > cat call.s
.file "call.c"
.text
.globl caller
.type caller, @function
caller:
pushl %ebp
movl %esp, %ebp
subl $8, %esp
movl $5, (%esp)
call callee
leave
ret
.size caller, .-caller
.ident "GCC: (GNU) 4.1.2 20080704 (Red Hat 4.1.2-44)"
.section .note.GNU-stack,"",@progbits

The point here is that '-mpush-args' is ineffective unless
'-mno-accumulate-outgoing-args' is given, and that the documentation,
in my opinion, may be misleading by

a) not mentioning the -mno-accumulate-outgoing-args switch

b) saying that '-mpush-args' is the default when it's an ineffective
default (since the default -maccumulate-outgoing-args appears to
override it)

c) not mentioning that -maccumulate-outgoing-args is the default - in
fact, the discussion in the section of push-args/no-push-args appears
to imply that it shouldn't be the default.

Thanks.

- Godmar
Ian Lance Taylor
2009-09-01 16:31:03 UTC
Permalink
Post by Godmar Back
It appears to me that '-mno-push-args' is the enabled by default (*),
and not '-mpush-args'.
The default varies by processor--it dependson the -mtune option.
Post by Godmar Back
Moreover, since -maccumulate-outgoing-args
implies -mno-push-args, it appears that the only way to obtain
'push-args' behavior is to specify '-mno-accumulate-outgoing-args' - a
switch which the documentation doesn't even mention.
That is likely true.

If you want to send a patch for the docs, that would be great.

Ian
Godmar Back
2009-09-01 18:40:25 UTC
Permalink
Post by Ian Lance Taylor
Post by Godmar Back
It appears to me that '-mno-push-args' is the enabled by default (*),
and not '-mpush-args'.
The default varies by processor--it dependson the -mtune option.
I don't know how to find out which tuning is enabled by default; I
assume -mtune=generic?
Would statements with respect to what "default" is apply to the
"default" mtune setting?
Post by Ian Lance Taylor
Post by Godmar Back
Moreover, since -maccumulate-outgoing-args
implies -mno-push-args, it appears that the only way to obtain
'push-args' behavior is to specify '-mno-accumulate-outgoing-args' - a
switch which the documentation doesn't even mention.
That is likely true.
If you want to send a patch for the docs, that would be great.
Whilst in general I am not opposed to this, and have contributed to
many open source projects in the past, I feel that the documentation
should be updated by someone who can actually vouch for the
completeness and accuracy of what's written, which I definitely
cannot. I also cannot verify the accuracy of the claims with respect
to speeds of the two options. Moreover, these claims are made in a
section of the documentation that applies to an entire architecture
rather than a specific processor implementation. Perhaps they should
simply be removed?

I'm also uncertain where exactly the difference between
accumulate-outgoing-args and push-args is.
accumulate implies no-push-arg, and no-accumulate+push-arg is the
traditional approach, but what does no-accumulate+no+push+arg look
like and does it even make sense?

It would also be great if '-mpush-args' without
-mno-accumulate-outgoing-args would trigger a warning:
Warning: -mpush-args ignored while -maccumulate-outgoing-args is in effect.

- Godmar

Loading...