From: Denis Zaitsev <zzz@anda.ru>
To: gcc@gcc.gnu.org
Cc: linux-gcc@vger.kernel.org
Subject: GCC 3.3.2 -Wall affects the code generated...
Date: Fri, 2 Jul 2004 00:03:03 +0600 [thread overview]
Message-ID: <20040702000303.A797@natasha.ward.six> (raw)
The long story is such: I was compiling GLIBC 2.3.2 and there is a
file libio/fileops.c which includes iconv/gconv_charset.h. In this
header an inline function named strip is defined. And I found that
the object code generated for this function depends of the presence of
-Wall in the list of option to GCC. (For some reason, GCC can't
inline this function, so it's compiled as just an outline one.) Is
this a bug in GCC?
Below I include the source code of this strip function and its
assembler generated with and without -Wall. I can say also, that it
seems that this libio/fileops.c file is kinda 'hard to compile'
source: another tho inline functions can't be inlined (and GCC
complains about that), GCC warns that yet another one function
'declared inline after being called', even though it's not true
(AFAIK) and GCC just silently refuse to do some other optimization
during the compilation.
The source code:
static inline void
strip (char *wp, const char *s)
{
int slash_count = 0;
while (*s != '\0')
{
if (__isalnum_l (*s, &_nl_C_locobj)
|| *s == '_' || *s == '-' || *s == '.')
*wp++ = __toupper_l (*s, &_nl_C_locobj);
else if (*s == '/')
{
if (++slash_count == 3)
break;
*wp++ = '/';
}
++s;
}
while (slash_count++ < 2)
*wp++ = '/';
*wp = '\0';
}
The command line:
gcc fileops.c -c -std=gnu99 -D__USE_STRING_INLINES -O2 -Wall -Winline -Wstrict-prototypes -Wwrite-strings -fno-align-functions -fno-align-jumps -fno-align-loops -fno-ident -fno-strength-reduce -mcpu=pentium -mpreferred-stack-boundary=2 -pipe -fPIC -g0 -fomit-frame-pointer -fexceptions -I../include -I. -I/home/src/zzz/lib/glibc/bld/libio -I.. -I../libio -I/home/src/zzz/lib/glibc/bld -I../sysdeps/i386/elf -I../linuxthreads/sysdeps/unix/sysv/linux/i386 -I../linuxthreads/sysdeps/unix/sysv/linux -I../linuxthreads/sysdeps/pthread -I../sysdeps/pthread -I../linuxthreads/sysdeps/unix/sysv -I../linuxthreads/sysdeps/unix -I../linuxthreads/sysdeps/i386/i586 -I../linuxthreads/sysdeps/i386 -I../sysdeps/unix/sysv/linux/i386 -I../sysdeps/unix/sysv/linux -I../sysdeps/gnu -I../sysdeps/unix/common -I../sysdeps/unix/mman -I../sysdeps/unix/inet -I../sysdeps/unix/sysv/i386 -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -I../sysdeps/unix -I../sysdeps/posix -I../sysdeps/i386/i586 -I../sysdeps/i386/i486 -I../sysdeps/i386/fpu -I../sysdeps/i386 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic/elf -I../sysdeps/generic -I /lib/modules/2.4.24/build/include -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DPIC -DSHARED -D_IO_MTSAFE_IO -o ...
The assembler (-Wall):
strip:
.LFB113:
pushl %ebp
.LCFI521:
xorl %ebp, %ebp
pushl %edi
.LCFI522:
pushl %esi
.LCFI523:
pushl %ebx
.LCFI524:
pushl %edi
.LCFI525:
call .L796
.L796:
popl %ebx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L796], %ebx
movl 28(%esp), %edi
movl 24(%esp), %esi
movb (%edi), %al
movb %al, 3(%esp)
testb %al, %al
je .L24
.L23:
movsbl 3(%esp),%edx
movl 52+_nl_C_locobj@GOTOFF(%ebx), %eax
testb $8, (%eax,%edx,2)
jne .L13
cmpb $95, 3(%esp)
je .L13
cmpb $45, 3(%esp)
je .L13
cmpb $46, 3(%esp)
je .L13
cmpb $47, 3(%esp)
je .L794
.L20:
incl %edi
movb (%edi), %al
movb %al, 3(%esp)
testb %al, %al
jne .L23
.L24:
movl %ebp, %eax
incl %ebp
decl %eax
jg .L795
movb $47, (%esi)
incl %esi
jmp .L24
.LCFI526:
.L795:
movb $0, (%esi)
popl %esi
.LCFI527:
popl %ebx
.LCFI528:
popl %esi
.LCFI529:
popl %edi
.LCFI530:
popl %ebp
.LCFI531:
ret
.L794:
incl %ebp
cmpl $3, %ebp
je .L24
movb $47, (%esi)
incl %esi
jmp .L20
.L13:
movsbl 3(%esp),%edx
movl 60+_nl_C_locobj@GOTOFF(%ebx), %eax
movl %esi, %ecx
incl %esi
movl (%eax,%edx,4), %eax
movb %al, (%ecx)
jmp .L20
.LFE113:
.size strip, .-strip
.type upstr, @function
The assembler (w/o -Wall):
strip:
.LFB113:
pushl %ebp
.LCFI521:
xorl %ebp, %ebp
pushl %edi
.LCFI522:
pushl %esi
.LCFI523:
pushl %ebx
.LCFI524:
pushl %edi
.LCFI525:
call .L797
.L797:
popl %ebx
addl $_GLOBAL_OFFSET_TABLE_+[.-.L797], %ebx
movl 28(%esp), %edi
movl 24(%esp), %esi
movb (%edi), %al
movb %al, 3(%esp)
testb %al, %al
je .L10
.L23:
movsbl 3(%esp),%edx
movl 52+_nl_C_locobj@GOTOFF(%ebx), %eax
testb $8, (%eax,%edx,2)
jne .L13
cmpb $95, 3(%esp)
je .L13
cmpb $45, 3(%esp)
je .L13
cmpb $46, 3(%esp)
je .L13
cmpb $47, 3(%esp)
je .L796
.L20:
incl %edi
movb (%edi), %al
movb %al, 3(%esp)
testb %al, %al
jne .L23
.L10:
movl %ebp, %eax
incl %ebp
decl %eax
jle .L27
.L795:
movb $0, (%esi)
popl %esi
.LCFI526:
popl %ebx
.LCFI527:
popl %esi
.LCFI528:
popl %edi
.LCFI529:
popl %ebp
.LCFI530:
ret
.L27:
movl %ebp, %eax
movb $47, (%esi)
incl %ebp
incl %esi
decl %eax
jle .L27
jmp .L795
.L796:
incl %ebp
cmpl $3, %ebp
je .L10
movb $47, (%esi)
incl %esi
jmp .L20
.L13:
movsbl 3(%esp),%edx
movl 60+_nl_C_locobj@GOTOFF(%ebx), %eax
movl %esi, %ecx
incl %esi
movl (%eax,%edx,4), %eax
movb %al, (%ecx)
jmp .L20
.LFE113:
.size strip, .-strip
.type upstr, @function
The diff (I omited all the parts that describe only the different
labels):
47,51c47
< jg .L795
< movb $47, (%esi)
< incl %esi
< jmp .L24
< .LCFI526:
---
> jle .L27
65c61,69
< .L794:
---
> .L27:
> movl %ebp, %eax
> movb $47, (%esi)
> incl %ebp
> incl %esi
> decl %eax
> jle .L27
> jmp .L795
> .L796:
next reply other threads:[~2004-07-01 18:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-07-01 18:03 Denis Zaitsev [this message]
2004-07-06 20:41 ` GCC 3.3.2 -Wall affects the code generated Jim Wilson
2004-07-06 21:11 ` John Richard Moser
2004-07-06 22:46 ` Denis Zaitsev
2004-07-07 0:20 ` Jim Wilson
2004-07-07 7:44 ` 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=20040702000303.A797@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).