linux-gcc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Denis Zaitsev <zzz@anda.ru>
To: gcc@gcc.gnu.org
Cc: linux-gcc@vger.kernel.org
Subject: [new-ra] GCC-3.3.2/x86: some suspicious behaviour
Date: Thu, 8 Jul 2004 04:06:43 +0600	[thread overview]
Message-ID: <20040708040643.E17650@natasha.ward.six> (raw)

This source


extern inline
void *i(void *d, void *s, int n)
{
    __asm__ __volatile__ ( ""
        :"+&c"(n), "+&D"(d), "+&S"(s)
    );
}
void *o(void *d, void *s, int n)
{
    return i(d, s, n);
}


is compiled into that assembler:


o:
	pushl	%edi
	pushl	%esi
	movl	12(%esp), %edi
	movl	16(%esp), %esi
	movl	20(%esp), %ecx
	popl	%esi
	popl	%edi
	ret


Everything looks ok.  But the source modified slightly


extern inline
void *i(void *d, void *s, int n)
{
    __asm__ __volatile__ ( ""
        :"+&c"(n), "+&D"(d), "+&S"(s)
    );
    __asm__ __volatile__ ( ""
        :"+&c"(n), "+&D"(d), "+&S"(s)
    );
}
void *o(void *d, void *s, int n)
{
    return i(d, s, n);
}


is compiled into that assembler:


o:
	pushl	%edi
	pushl	%esi
	movl	12(%esp), %edi
	movl	20(%esp), %ecx
	movl	16(%esp), %esi
	movl	%ecx, 16(%esp)
	movl	%esi, 20(%esp)
	popl	%esi
	popl	%edi
	ret


So, what does these two commands mean:


	movl	%ecx, 16(%esp)
	movl	%esi, 20(%esp)


?  The options for the compiler are:


-O2 -fomit-frame-pointer -fnew-ra


The result is the same for any -O >0 and for -Os.  And the presence of
these suspicious commands are not affected by the frame-pointer
option.

             reply	other threads:[~2004-07-07 22:06 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-07 22:06 Denis Zaitsev [this message]
2004-07-08 14:46 ` [new-ra] GCC-3.3.2/x86: some suspicious behaviour Michael Matz
2004-07-08 16:31   ` Denis Zaitsev
2004-07-08 16:52     ` Paul Brook
2004-07-08 17:18       ` Denis Zaitsev

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040708040643.E17650@natasha.ward.six \
    --to=zzz@anda.ru \
    --cc=gcc@gcc.gnu.org \
    --cc=linux-gcc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).