jump after return
Ian Lance Taylor
iant@google.com
Fri Nov 12 06:56:00 GMT 2010
Alain Ketterlin <alain.ketterlin@gmail.com> writes:
> When compiling at -O2 and -O3 optimization, I've found several
> instances of routines ending with:
>
> retq
> jmp <address-of-next-routine>
>
> with no branch pointing to the jmp instruction. Is there any specific
> reason for such code? Is there a way to avoid this?
>
> This is gcc 4.4.5, as installed on Ubuntu 10.10, compiling the SPEC
> OMP and CPU-2006 benchmarks.
This question borders on being more appropriate for the mailing list
gcc-help@gcc.gnu.org than for the gcc@gcc.gnu.org mailing list. Please
consider whether to use gcc-help for future questions. Thanks.
It always helps to give a specific example, and to mention the specific
target--I infer x86, but 32-bit or 64-bit? Which specific processor, or
in other words which -mtune option?
In any case I would guess that it is due to -falign-functions. The x86
GNU assembler does alignment by inserting nops, and if it needs to align
more than some number of bytes it does it using a jump instruction. For
some x86 tuning targets the default for -falign-functions is 32, and gas
will certainly use a jmp if it has to skip more than 15 bytes.
Ian
More information about the Gcc
mailing list