public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/27781]  New: weak-attribute over-optimisation with 4.1
@ 2006-05-28  9:39 jan dot kiszka at web dot de
  2006-05-28 12:04 ` [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation rguenth at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: jan dot kiszka at web dot de @ 2006-05-28  9:39 UTC (permalink / raw)
  To: gcc-bugs

file-a.c:
---------
void __attribute__((weak)) func(void)
{
    /* no code */
}

main()
{
    func();
}


file-b.c:
---------
void func(void)
{
    printf("func\n");
}


# gcc -c file-a.c file-b.c -O2
# gcc -o program file-a.o file-b.o

The program will not print "func", because the call to func() was optimised out
during the compilation of file-a.c. This happens with -O2, but not when using
-fno-unit-at-a-time. First sighted in 4.1.


-- 
           Summary: weak-attribute over-optimisation with 4.1
           Product: gcc
           Version: 4.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: jan dot kiszka at web dot de


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
@ 2006-05-28 12:04 ` rguenth at gcc dot gnu dot org
  2006-05-28 14:00 ` rguenth at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-28 12:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from rguenth at gcc dot gnu dot org  2006-05-28 12:03 -------
ipa-pure-const thinks that func is const, which is wrong.  Then DCE comes along
and deletes the function call.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |rguenth at gcc dot gnu dot
                   |                            |org
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
           Keywords|                            |wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2006-05-28 12:03:59
               date|                            |
            Summary|weak-attribute over-        |[4.1/4.2 Regression] weak-
                   |optimisation with 4.1       |attribute over-optimisation
   Target Milestone|---                         |4.1.2


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
  2006-05-28 12:04 ` [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation rguenth at gcc dot gnu dot org
@ 2006-05-28 14:00 ` rguenth at gcc dot gnu dot org
  2006-05-28 15:23 ` [Bug middle-end/27781] " pinskia at gcc dot gnu dot org
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-05-28 14:00 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from rguenth at gcc dot gnu dot org  2006-05-28 14:00 -------
I have a patch.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |rguenth at gcc dot gnu dot
                   |dot org                     |org
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-05-28 12:03:59         |2006-05-28 14:00:23
               date|                            |


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
  2006-05-28 12:04 ` [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation rguenth at gcc dot gnu dot org
  2006-05-28 14:00 ` rguenth at gcc dot gnu dot org
@ 2006-05-28 15:23 ` pinskia at gcc dot gnu dot org
  2006-06-01 18:36 ` trini at kernel dot crashing dot org
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-05-28 15:23 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2006-05-28 15:23 -------
Actually no, you have to use -fPIC to get this not to be optimized, otherwise
func will be bound locally which is not what you want.


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|c                           |middle-end


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (2 preceding siblings ...)
  2006-05-28 15:23 ` [Bug middle-end/27781] " pinskia at gcc dot gnu dot org
@ 2006-06-01 18:36 ` trini at kernel dot crashing dot org
  2006-06-04 19:32 ` mmitchel at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: trini at kernel dot crashing dot org @ 2006-06-01 18:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from trini at kernel dot crashing dot org  2006-06-01 18:36 -------
(In reply to comment #3)
> Actually no, you have to use -fPIC to get this not to be optimized, otherwise
> func will be bound locally which is not what you want.

Two things.  First, that's a change in behavior from how it used to work and I
don't recall seeing warnings about going-away behavior (the place this problem
is actually manifesting is in code for the Linux Kernel).

Second there is some sort of bug here as if we have:
$ cat file-a.c
void __attribute__((weak)) func(void)
{
        printf("weak\n");
}

main()
{
            func();
}
$ cat file-b.c
void func(void)
{
        printf("func\n");
}
$ gcc-4.1 -c file-a.c file-b.c -O2
file-a.c: In function 'func':
file-a.c:3: warning: incompatible implicit declaration of built-in function
'printf'
file-b.c: In function 'func':
file-b.c:3: warning: incompatible implicit declaration of built-in function
'printf'
$ gcc-4.1 -o program file-a.o file-b.o
$ ./program
func
$ gcc-4.1 -o program file-a.o
$ ./program
weak
$ gcc-4.1 -v
Using built-in specs.
Target: x86_64-linux-gnu
Configured with: ../src/configure -v
--enable-languages=c,c++,java,fortran,objc,obj-c++,ada,treelang --prefix=/usr
--enable-shared --with-system-zlib --libexecdir=/usr/lib
--without-included-gettext --enable-threads=posix --enable-nls
--program-suffix=-4.1 --enable-__cxa_atexit --enable-clocale=gnu
--enable-libstdcxx-debug --enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.4.2-gcj-4.1-1.4.2.0/jre --enable-mpfr
--enable-checking=release x86_64-linux-gnu
Thread model: posix
gcc version 4.1.0 (Debian 4.1.0-1)


-- 

trini at kernel dot crashing dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |trini at kernel dot crashing
                   |                            |dot org


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (3 preceding siblings ...)
  2006-06-01 18:36 ` trini at kernel dot crashing dot org
@ 2006-06-04 19:32 ` mmitchel at gcc dot gnu dot org
  2006-06-15 15:54 ` patchapp at dberlin dot org
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: mmitchel at gcc dot gnu dot org @ 2006-06-04 19:32 UTC (permalink / raw)
  To: gcc-bugs



-- 

mmitchel at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P3                          |P2


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (4 preceding siblings ...)
  2006-06-04 19:32 ` mmitchel at gcc dot gnu dot org
@ 2006-06-15 15:54 ` patchapp at dberlin dot org
  2006-06-15 17:30 ` rguenth at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: patchapp at dberlin dot org @ 2006-06-15 15:54 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from patchapp at dberlin dot org  2006-06-15 15:30 -------
Subject: Bug number PR27781

A patch for this bug has been added to the patch tracker.
The mailing list url for the patch is
http://gcc.gnu.org/ml/gcc-patches/2006-06/msg00808.html


-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1/4.2 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (5 preceding siblings ...)
  2006-06-15 15:54 ` patchapp at dberlin dot org
@ 2006-06-15 17:30 ` rguenth at gcc dot gnu dot org
  2006-06-15 17:39 ` [Bug middle-end/27781] [4.1 " rguenth at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-15 17:30 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from rguenth at gcc dot gnu dot org  2006-06-15 17:23 -------
Subject: Bug 27781

Author: rguenth
Date: Thu Jun 15 17:23:41 2006
New Revision: 114681

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114681
Log:
2006-06-16  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/27781
        * Makefile.in (ipa-pure-const.o): Add $(TARGET_H) dependency.
        * ipa-pure-const.c (target.h): Include.
        (analyze_function): Do not analyze functions that do not
        bind locally.

        * gcc.dg/tree-ssa/pr27781.c: New testcase.

Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr27781.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/Makefile.in
    trunk/gcc/ipa-pure-const.c
    trunk/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (6 preceding siblings ...)
  2006-06-15 17:30 ` rguenth at gcc dot gnu dot org
@ 2006-06-15 17:39 ` rguenth at gcc dot gnu dot org
  2006-06-16 17:53 ` pinskia at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-15 17:39 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from rguenth at gcc dot gnu dot org  2006-06-15 17:30 -------
Fixed on the mainline.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Summary|[4.1/4.2 Regression] weak-  |[4.1 Regression] weak-
                   |attribute over-optimisation |attribute over-optimisation


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (7 preceding siblings ...)
  2006-06-15 17:39 ` [Bug middle-end/27781] [4.1 " rguenth at gcc dot gnu dot org
@ 2006-06-16 17:53 ` pinskia at gcc dot gnu dot org
  2006-06-21 15:36 ` rguenth at gcc dot gnu dot org
  2006-06-21 15:43 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-06-16 17:53 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pinskia at gcc dot gnu dot org  2006-06-16 17:50 -------
*** Bug 28055 has been marked as a duplicate of this bug. ***


-- 

pinskia at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |saito at densan dot co dot
                   |                            |jp


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (8 preceding siblings ...)
  2006-06-16 17:53 ` pinskia at gcc dot gnu dot org
@ 2006-06-21 15:36 ` rguenth at gcc dot gnu dot org
  2006-06-21 15:43 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-21 15:36 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #9 from rguenth at gcc dot gnu dot org  2006-06-21 15:36 -------
Fixed.


-- 

rguenth at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Bug middle-end/27781] [4.1 Regression] weak-attribute over-optimisation
  2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
                   ` (9 preceding siblings ...)
  2006-06-21 15:36 ` rguenth at gcc dot gnu dot org
@ 2006-06-21 15:43 ` rguenth at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2006-06-21 15:43 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #10 from rguenth at gcc dot gnu dot org  2006-06-21 15:36 -------
Subject: Bug 27781

Author: rguenth
Date: Wed Jun 21 15:36:10 2006
New Revision: 114852

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=114852
Log:
2006-06-21  Richard Guenther  <rguenther@suse.de>

        PR tree-optimization/27781
        * Makefile.in (ipa-pure-const.o): Add $(TARGET_H) dependency.
        * ipa-pure-const.c (target.h): Include.
        (analyze_function): Do not analyze functions that do not
        bind locally.

        * gcc.dg/tree-ssa/pr27781.c: New testcase.

Added:
    branches/gcc-4_1-branch/gcc/testsuite/gcc.dg/tree-ssa/pr27781.c
      - copied unchanged from r114681,
trunk/gcc/testsuite/gcc.dg/tree-ssa/pr27781.c
Modified:
    branches/gcc-4_1-branch/gcc/ChangeLog
    branches/gcc-4_1-branch/gcc/Makefile.in
    branches/gcc-4_1-branch/gcc/ipa-pure-const.c
    branches/gcc-4_1-branch/gcc/testsuite/ChangeLog


-- 


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


^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2006-06-21 15:36 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-28  9:39 [Bug c/27781] New: weak-attribute over-optimisation with 4.1 jan dot kiszka at web dot de
2006-05-28 12:04 ` [Bug c/27781] [4.1/4.2 Regression] weak-attribute over-optimisation rguenth at gcc dot gnu dot org
2006-05-28 14:00 ` rguenth at gcc dot gnu dot org
2006-05-28 15:23 ` [Bug middle-end/27781] " pinskia at gcc dot gnu dot org
2006-06-01 18:36 ` trini at kernel dot crashing dot org
2006-06-04 19:32 ` mmitchel at gcc dot gnu dot org
2006-06-15 15:54 ` patchapp at dberlin dot org
2006-06-15 17:30 ` rguenth at gcc dot gnu dot org
2006-06-15 17:39 ` [Bug middle-end/27781] [4.1 " rguenth at gcc dot gnu dot org
2006-06-16 17:53 ` pinskia at gcc dot gnu dot org
2006-06-21 15:36 ` rguenth at gcc dot gnu dot org
2006-06-21 15:43 ` rguenth at gcc dot gnu dot org

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).