[Bug tree-optimization/52734] [4.7/4.8 Regression] Incorrect optimization of uClibc sbrk()

2012-04-10 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52734

--- Comment #13 from Sedat Dilek  2012-04-10 
22:57:15 UTC ---
Just some remarks:

Freetz is an OSS project supporting router (platforms) of a popular German
company. The target-system is mostly MIPS(EL). The majority of our developers
build on AMD64 hosts (32bit-toolchain).
The full patchset for gcc-4.7.0 can be found in [1].
Jörg provided his adapted/backported patch in [2].
Thank you for testing!

[0] http://freetz.org/
[1] http://freetz.org/browser/trunk/toolchain/make/target/gcc/4.7.0/
[2] http://freetz.org/attachment/ticket/1752/r8889-gcc-4.7-fix.patch


[Bug tree-optimization/52734] [4.7/4.8 Regression] Incorrect optimization of uClibc sbrk()

2012-04-13 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52734

--- Comment #17 from Sedat Dilek  2012-04-13 
19:38:24 UTC ---
Thanks, Tom!


[Bug tree-optimization/49618] New: When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-03 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

   Summary: When building uClibc with GCC 4.6.1 old_atexit is
miscompiled
   Product: gcc
   Version: unknown
Status: UNCONFIRMED
  Severity: normal
  Priority: P3
 Component: tree-optimization
AssignedTo: unassig...@gcc.gnu.org
ReportedBy: sedat.di...@gmail.com


Created attachment 24661
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24661
Preprocessed file "old_atexit.i"

Hi,

this issue kept me UP for several weeks. It first occured when generating a
mipsel target-toolchain based on gcc-4.6.0 with uClibc-0.9.32 for a router
project called freetz. Finally, I could track the problem with the assistance
from Edwin Török. A big thank you, Edwin.

### Problem description:

When building uClibc with GCC 4.6.1 old_atexit is miscompiled, which causes
this testprogram to crash when calling old_atexit:

#include 
void foo() {}
int main() { return atexit(foo);}

This is a regression from GCC 4.5.3 which compiled old_atexit() fine.

Attached is the preprocessed file old_atexit.i.

Commandline to create old_atexit.os:

mipsel-linux-uclibc-gcc -S old_atexit.i -o old_atexit.os -funsigned-char
-fno-builtin -fno-asm -msoft-float -std=gnu99 -march=4kc -mtune=4kc -mabi=32
-fno-stack-protector -Os -funit-at-a-time
-fmerge-all-constants -fstrict-aliasing -fno-tree-loop-optimize
-fno-tree-dominator-opts -fno-strength-reduce -mno-split-addresses -fPIC

As seen below with GCC 4.6.1 &__dso_handle is assumed to be non-NULL
and the branch (beqz) eliminated, but it is in fact NULL at runtime
which causes the crash.
With GCC 4.5.3 there is a beqz that tests for &__dso_handle == NULL:

000537d0 :
  537d0:   3c1c0003lui gp,0x3
  537d4:   279c8d10addiu   gp,gp,-29424
  537d8:   0399e021addugp,gp,t9
  537dc:   8f828a2clw  v0,-30164(gp)
  537e0:   8f9989aclw  t9,-30292(gp)
  537e4:   8c46lw  a2,0(v0)
  ^^ SIGSEGV here, with a NULL dereference
  537e8:   2821movea1,zero
  537ec:   0328jr  t9
  537f0:   0002300amovza2,zero,v0

old_atexit.os with GCC 4.6.1:
   .file   1 "old_atexit.c"
   .section .mdebug.abi32
   .previous
   .gnu_attribute 4, 3
   .abicalls
   .text
   .align  2
   .globl  old_atexit
   .setnomips16
   .entold_atexit
   .type   old_atexit, @function
old_atexit:
   .frame  $sp,0,$31   # vars= 0, regs= 0/0, args= 0, gp= 0
   .mask   0x,0
   .fmask  0x,0
   .setnoreorder
   .cpload $25
   .setnomacro
   lw  $2,%got(__dso_handle)($28)
   lw  $25,%call16(__cxa_atexit)($28)
   lw  $6,0($2)
   move$5,$0
   .reloc  1f,R_MIPS_JALR,__cxa_atexit
1:  jr  $25
   movz$6,$0,$2

   .setmacro
   .setreorder
   .endold_atexit
   .size   old_atexit, .-old_atexit
   .weak   atexit
   atexit = old_atexit
   .weak   __dso_handle
   .ident  "GCC: (GNU) 4.6.1"

old_atexit.os with GCC 4.5.3:
   .file   1 "old_atexit.c"
   .section .mdebug.abi32
   .previous
   .gnu_attribute 4, 3
   .abicalls
   .text
   .align  2
   .globl  old_atexit
   .setnomips16
   .entold_atexit
   .type   old_atexit, @function
old_atexit:
   .frame  $sp,0,$31   # vars= 0, regs= 0/0, args= 0, gp= 0
   .mask   0x,0
   .fmask  0x,0
   .setnoreorder
   .cpload $25
   .setnomacro
   lw  $2,%got(__dso_handle)($28)
   beq $2,$0,$L2
   move$6,$0

   lw  $6,0($2)
$L2:
   lw  $25,%call16(__cxa_atexit)($28)
   .reloc  1f,R_MIPS_JALR,__cxa_atexit
1:  jr  $25
   move$5,$0

   .setmacro
   .setreorder
   .endold_atexit
   .size   old_atexit, .-old_atexit
   .weak   atexit
   atexit = old_atexit
   .weak   __dso_handle
   .ident  "GCC: (GNU) 4.5.3"

### GCC versions (with gcc -v output) for target and host:

$
/mnt/sdb3/freetz/freetz-trunk_gcc-4.6.1/toolchain/build/mipsel_gcc-4.6.1_uClibc-0.9.32/mipsel-linux-uclibc/bin/mipsel-linux-uclibc-gcc
-v
Using built-in specs.
COLLECT_GCC=/mnt/sdb3/freetz/freetz-trunk_gcc-4.6.1/toolchain/build/mipsel_gcc-4.6.1_uClibc-0.9.32/mipsel-linux-uclibc/bin/mipsel-linux-uclibc-gcc
COLLECT_LTO_WRAPPER=/mnt/sdb3/freetz/freetz-trunk_gcc-4.6.1/toolchain/build/mipsel_gcc-4.6.1_uClibc-0.9.32/mipsel-linux-uclibc/bin/../libexec/gcc/mipsel-linux-uclibc/4.6.1/lto-wrapper
Target: mipsel-linux-uclibc
Configured with:
/mnt/sdb3/freetz/freetz-trunk/source/toolchain-mipsel_gcc-4.6.1_uClibc-0.9.32/gcc-4.6.1/configure
--prefix=/mnt/sdb3/freetz/freetz-trunk/toolchain/build/mipsel_gcc-4.6.1_uClibc-0.9.32/mipsel-linux-uclibc
--with-sysroot=/mnt/sdb3/

[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-03 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #3 from dileks  2011-07-03 15:39:02 
UTC ---
Short feedback: -O{0,1,2,} works (beq* is there), -Os doesn't (beq deleted).

[ -O0 ]
beq$2,$0,$L2

[ -O1 ]
beql$2,$0,$L3

[ -O2 ]
beql$2,$0,$L2

[ -Os ]
[ empty ]


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-03 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #4 from Sedat Dilek  2011-07-03 
17:46:07 UTC ---
With the Patch from [1] I could boot a firmware-image on my router.

[1]
http://freetz.org/attachment/ticket/1310/gcc-4.6.x-disable-if-conversion.patch


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-03 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #8 from Sedat Dilek  2011-07-03 
20:47:37 UTC ---
Confirmed... Image built with gcc-4.6.x-disable-opt-flags.patch works also
fine.


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #13 from Sedat Dilek  2011-07-04 
14:29:27 UTC ---
Confirmed... gcc46-pr49618.patch solves the problem here, workaround patches
from freetz project are no more necessary.


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #14 from Sedat Dilek  2011-07-04 
14:38:05 UTC ---
Thank you gcc folks and all involved people to fix this bug.


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #15 from Sedat Dilek  2011-07-04 
16:47:25 UTC ---
Created attachment 24677
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24677
Simple testcase-script for gcc-PR49618


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #17 from Sedat Dilek  2011-07-04 
16:48:44 UTC ---
Created attachment 24679
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24679
old_atexit.os_OptLevel-O1


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #20 from Sedat Dilek  2011-07-04 
16:50:10 UTC ---
Created attachment 24682
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24682
old_atexit.os_OptLevel-Os


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #18 from Sedat Dilek  2011-07-04 
16:49:13 UTC ---
Created attachment 24680
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24680
old_atexit.os_OptLevel-O2


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #19 from Sedat Dilek  2011-07-04 
16:49:44 UTC ---
Created attachment 24681
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24681
old_atexit.os_OptLevel-O3


[Bug tree-optimization/49618] When building uClibc with GCC 4.6.1 old_atexit is miscompiled

2011-07-04 Thread sedat.dilek at gmail dot com
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49618

--- Comment #16 from Sedat Dilek  2011-07-04 
16:48:15 UTC ---
Created attachment 24678
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24678
old_atexit.os_OptLevel-O0