Feature request concerning opcodes in the function prolog
amylaar@spamcop.net
amylaar@spamcop.net
Thu Jan 8 14:38:00 GMT 2009
Quoting Stefan Dösinger <stefan@codeweavers.com>:
> I talked to Alexandre again, and his main concern wasn't so much the global
> flag, but that the existance of the push %ebp; mov %esp, %ebp was still up
> to the feelings of the compiler and the moon phase.
>
> So what he wants is something like a msvc_prolog attribute that makes sure
> that the function starts with the following instructions and bytecode
> sequence, no matter what -fomit-frame-pointer and friends say:
>
> 8b ff mov.s %edi, %edi
> 55 push %ebp
> 8b ec mov.s %esp, %ebp
>
> So we basically need the msvc_prolog to add the "mov.s %edi, %edi" and force
> the frame pointer on,
You don't need to force the frame pointer on, it is sufficient to say that
ebp needs restoring at the end of the function no matter if it looks otherwise
used or not - and you have to take the frame size impact of the saved ebp into
account.
Moreover, if your prologue beings with an unspec_volatile that emits the
three-instruction sequence you want, the optimizers should leave it there
at the start of the function.
Although it is properly easiest to get debug and unwind information right
if you make this three separate unspec_volatile patterns, with their
respective REG_FRAME_RELATED_EXPR notes where applicable.
I.e. the push ebp saves ebp and changes the stack.
The mov.s esp,ebp needs a REG_FRAME_RELATED_EXPR note only if you are
actually using a frame pointer.
More information about the Gcc
mailing list