This is the mail archive of the gcc-bugs@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]

strange move of __asm__


Hi,

WINE contains the following function:

TEB * WINAPI NtCurrentTeb(void)
{
#ifdef __i386__
    TEB *teb;

    /* Get the TEB self-pointer */
    __asm__( ".byte 0x64\n\tmovl (%1),%0"
             : "=r" (teb) : "r" (&((TEB *)0)->self) );
    return teb;
#else
    return &pCurrentThread->teb;
#endif  /* __i386__ */
}

(WINAPI is a #define for __attribute__((__stdcall__)), TEB is a struct)

It compiles to the following (correct working) assemblercode on i386 on
"gcc version egcs-2.93.12 19990314 (gcc2 ss-980929 experimental)":

000000fc <NtCurrentTeb>:
  fc:   b8 18 00 00 00  movl   $0x18,%eax
 101:   64 8b 00        movl   %fs:(%eax),%eax
 104:   55              pushl  %ebp
 105:   89 e5           movl   %esp,%ebp
 107:   89 ec           movl   %ebp,%esp
 109:   5d              popl   %ebp
 10a:   c3              ret    

egcs has moved the __asm__ outside the stackframe enter/leave. Now,
should this happen?
And couldn't egcs optimize the framestuff away if nothing is inside it?

Ciao, Marcus


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