This is the mail archive of the gcc@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]
Other format: [Raw text]

RE: Feature request concerning opcodes in the function prolog


Here's some code attached that actually works, but is far from perfect.

The 'msvc_prologue' attribute is limited to 32 bit. None of the applications
that try to place hooks are ported to Win64 yet, so it is impossible to tell
what they'll need. Besides, maybe I am lucky that when they appear I can
tell their autors to think about Wine.

The first problem I (still) have is passing the msvc_prologue attribute
around. I abused some other code to do that. How does the attribute handling
work, and what would the prefered way be?

The 2nd thing I have to figure out is how and when I have to set
REG_FRAME_RELATED_EXPR.

The msvc_prologue + frame_pointer_needed + !stack_realignment_needed case
produces the best possible code. The fp setup from msvc_prologue is used for
its purpose.

The msvc_prologue + !frame_pointer_needed case could be optimized, as you
said. However, that changes all the stack frame offsets and sizes, and I do
not quite understand all the code I have to modify for that. I think this
should be a separate patch, although arguably be ready before msvc_prologue
is added. I personally don't care too much about this combination of
parameters(Wine won't need/use it), so this optimization would get lost
otherwise.

With stack_realignment_needed frame_pointer_needed is on as well, and this
code is created(copypasted together by hand, somehow the stack alignment
attribute doesn't do anything on my Linux box)

movl.s %edi, %edi
pushl  %ebp
movl.s %esp, %ebp
pop    %ebp
lea    0x4(%esp),%ecx
and    $0xfffffff0,%esp
pushl  -0x4(%ecx)
push   %ebp	
mov    %esp,%ebp

If we try to get rid of the pop-push-mov, the following things change:

*) The value of %ebp
*) The location of the pushed ebp on the stack
*) The alignment of %esp after the whole procedure(its alignment+4 before,
and the +4 is lost afterwards)

Now the question is, what parts are important for the stack realignment
attribute? I think we can't correct point 2. If we correct (1) and (3) this
has to be done with less than 3-4 extra instructions if it should be worth
the effort. I don't see any code right now that would accomplish that, but
maybe I'm missing something.

Attachment: msvc.diff
Description: Binary data


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