public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "vda dot linux at googlemail dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug rtl-optimization/29950]  New: Generated code changes after unrelated edits in source.
Date: Wed, 22 Nov 2006 22:56:00 -0000	[thread overview]
Message-ID: <bug-29950-12956@http.gcc.gnu.org/bugzilla/> (raw)

I noticed that sizes of functions in generated code change when I do simple
unrelated changes. Example:

# diff -u vi_small.c vi_big.c
--- vi_small.c  2006-11-22 23:35:39.000000000 +0100
+++ vi_big.c    2006-11-22 23:35:42.000000000 +0100
@@ -3414,6 +3414,8 @@
 } sockaddr_inet;
 extern int dotted2sockaddr(const char *dotted, struct sockaddr* sp, int
socklen);
 extern int create_and_bind_socket_ip4or6(const char *hostaddr, int port);
+extern int setsockopt_reuseaddr(int fd);
+extern int setsockopt_reuseaddr2(int fd);
 extern char *xstrdup(const char *s);
 extern char *xstrndup(const char *s, int n);
 extern char *safe_strncpy(char *dst, const char *src, size_t size);

Both .c files have this simple function at the end:

Byte *find_pair(Byte * p, Byte c)
{
 Byte match, *q;
 int dir, level;
 match = ')';
 level = 1;
 dir = 1;
 switch (c) {
 case '(':
  match = ')';
  break;
 case '[':
  match = ']';
  break;
 case '{':
  match = '}';
  break;
 case ')':
  match = '(';
  dir = -1;
  break;
 case ']':
  match = '[';
  dir = -1;
  break;
 case '}':
  match = '{';
  dir = -1;
  break;
 }
 for (q = p + dir; text <= q && q < end; q += dir) {
  if (*q == c)
   level++;
  if (*q == match)
   level--;
  if (level == 0)
   break;
 }
 if (level != 0)
  q = ((void *)0);
 return (q);
}

which is obviously does not depend on setsockopt_reuseaddr[2].
I made two extra copies of it, just for fun, but it happens without copies too.
Okay, when I compile those:

#!/bin/sh
function compile() {
    gcc -fno-builtin-strlen -Os "$@"
}
compile -c -o vi_small.o vi_small.c
compile -c -o vi_big.o   vi_big.c
nm --size-sort vi_small.o | grep find_pair
nm --size-sort vi_big.o   | grep find_pair

I am getting:

000000a9 T find_pair   (vi_small.c)
000000a9 T find_pairB
000000a9 T find_pairC

000000a9 T find_pairB  (vi_big.c)
000000a9 T find_pairC
000000b9 T find_pair   <--------- different??

How come gcc generates different code for identical source files?
You saw the diff, it cannot matter at all...
How come gcc generates different code for identical functions???
(vi_big.c:find_pairB is the same as vi_big.c:find_pair to the last byte)

# gcc -v
Using built-in specs.
Target: i386-pc-linux-gnu
Configured with: ../gcc-4.1.1.org/configure --prefix=/usr/app/gcc-4.1.1.org
--exec-prefix=/usr/app/gcc-4.1.1.org --bindir=/usr/bin --sbindir=/usr/sbin
--libexecdir=/usr/app/gcc-4.1.1.org/libexec
--datadir=/usr/app/gcc-4.1.1.org/share --sysconfdir=/etc
--sharedstatedir=/usr/app/gcc-4.1.1.org/var/com
--localstatedir=/usr/app/gcc-4.1.1.org/var --libdir=/usr/lib
--includedir=/usr/include --infodir=/usr/info --mandir=/usr/man
--with-slibdir=/usr/app/gcc-4.1.1.org/lib --with-local-prefix=/usr/local
--with-gxx-include-dir=/usr/app/gcc-4.1.1.org/include/g++-v3
--enable-languages=c,c++ --with-system-zlib --disable-nls
--enable-threads=posix i386-pc-linux-gnu
Thread model: posix
gcc version 4.1.1


-- 
           Summary: Generated code changes after unrelated edits in source.
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: rtl-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: vda dot linux at googlemail dot com
 GCC build triplet: i386-pc-linux-gnu
  GCC host triplet: i386-pc-linux-gnu
GCC target triplet: i386-pc-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29950


             reply	other threads:[~2006-11-22 22:56 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-22 22:56 vda dot linux at googlemail dot com [this message]
2006-11-22 22:57 ` [Bug rtl-optimization/29950] " vda dot linux at googlemail dot com
2006-11-22 22:59 ` vda dot linux at googlemail dot com
2006-11-24  2:51 ` pinskia at gcc dot gnu dot org
2007-07-21 23:42 ` vda dot linux at googlemail dot com
2007-08-28 14:49 ` vda dot linux at googlemail dot com
2007-08-31  1:47 ` pinskia at gcc dot gnu dot org
2007-08-31 11:30 ` vda dot linux at googlemail dot com
2008-03-29  0:57 ` pinskia at gcc dot gnu dot org

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=bug-29950-12956@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.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 read-only IMAP folder(s) and NNTP newsgroup(s).