This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug inline-asm/67944] GCC emits unnecessary push/pop for callee-save reads.
- From: "segher at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 13 Oct 2015 13:09:54 +0000
- Subject: [Bug inline-asm/67944] GCC emits unnecessary push/pop for callee-save reads.
- Auto-submitted: auto-generated
- References: <bug-67944-4 at http dot gcc dot gnu dot org/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=67944
--- Comment #3 from Segher Boessenkool <segher at gcc dot gnu.org> ---
Your expectation is not in line with what the compiler actually promises
you: the only guarantee is that the local register variable will be in
(in your case) ebx _where used in an asm statement_.
Other than that, it is just a local variable.
You get a save/restore sequence in the prologue and epilogue because ebx
is a non-volatile register and this function uses that register. Scheduling
later moves the push later in the code.
If you want to simply grab what is in ebx, you can use asm, like
long reg; asm("mov %%ebx,%0" : "=r"(reg));