public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/38644]  New: Optimization flag -O1 -fschedule-insns2 causes wrong code
@ 2008-12-27 22:11 davejmurphy at me dot com
  2010-08-12 10:00 ` [Bug rtl-optimization/38644] [4.3/4.4/4.5/4.6 Regression] " steven at gcc dot gnu dot org
                   ` (12 more replies)
  0 siblings, 13 replies; 56+ messages in thread
From: davejmurphy at me dot com @ 2008-12-27 22:11 UTC (permalink / raw)
  To: gcc-bugs

The -fschedule-insns2 optimisation causes wrong code to be emitted for the
following testcase. The assembly code loads a value from a stack frame which
has already been deallocated.

This is similar to http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30282 for
powerpc-eabi.

extern int doStreamReadBlock(int *, char *, int size, int);

char readStream(int *s)
{
    char c = 0;
    doStreamReadBlock(s, &c, 1, *s);
    return c;
}

arm-eabi davem$ arm-eabi-gcc -v -O2 -mthumb -c test.c 
Using built-in specs.
Target: arm-eabi
Configured with: ../../gcc-4.3.2/configure --enable-languages=c,c++
--with-cpu=arm7tdmi --enable-interwork --enable-multilib --with-gcc
--with-gnu-ld --with-gnu-as --disable-shared --disable-threads
--disable-win32-registry --disable-nls --disable-debug --disable-libmudflap
--disable-libssp --disable-libgomp --disable-libstdcxx-pch --target=arm-eabi
--with-newlib --prefix=/opt/devkitpro/devkitARM
--with-bugurl=http://wiki.devkitpro.org/index.php/Bug_Reports
--with-pkgversion='devkitARM release 24'
Thread model: single
gcc version 4.3.2 (devkitARM release 24) 

00000000 <readStream>:
   0:   b510            push    {r4, lr}
   2:   b082            sub     sp, #8
   4:   466c            mov     r4, sp
   6:   3407            adds    r4, #7
   8:   2300            movs    r3, #0
   a:   7023            strb    r3, [r4, #0]
   c:   1c21            adds    r1, r4, #0
   e:   6803            ldr     r3, [r0, #0]
  10:   2201            movs    r2, #1
  12:   f7ff fffe       bl      0 <doStreamReadBlock>
  16:   b002            add     sp, #8          <--- stack frame deallocated
  18:   7820            ldrb    r0, [r4, #0]    <--- value loaded from stack
frame
  1a:   bc10            pop     {r4}
  1c:   bc02            pop     {r1}
  1e:   4708            bx      r1

The same thing happens with mainline

 /opt/devkitpro/devkitARM_mainline/bin/arm-eabi-gcc -v -O2 -mthumb -c test.c 
Using built-in specs.
Target: arm-eabi
Configured with: ../../../gcc_mainline/configure --disable-nls
--target=arm-eabi --prefix=/opt/devkitPro/devkitARM --enable-languages=c,c++
--with-cpu=arm7tdmi --enable-interwork --enable-multilib --with-gcc
--with-gnu-ld --with-gnu-as --disable-shared --disable-threads
--disable-win32-registry --disable-nls --disable-debug --disable-libmudflap
--disable-libssp --disable-libgomp --disable-libstdcxx-pch
Thread model: single
gcc version 4.4.0 20081223 (experimental) (GCC) 

00000000 <readStream>:
   0:   b510            push    {r4, lr}
   2:   b082            sub     sp, #8
   4:   466c            mov     r4, sp
   6:   3407            adds    r4, #7
   8:   2300            movs    r3, #0
   a:   7023            strb    r3, [r4, #0]
   c:   1c21            adds    r1, r4, #0
   e:   6803            ldr     r3, [r0, #0]
  10:   2201            movs    r2, #1
  12:   f7ff fffe       bl      0 <doStreamReadBlock>
  16:   b002            add     sp, #8
  18:   7820            ldrb    r0, [r4, #0]
  1a:   bc10            pop     {r4}
  1c:   bc02            pop     {r1}
  1e:   4708            bx      r1


-- 
           Summary: Optimization flag -O1 -fschedule-insns2 causes wrong
                    code
           Product: gcc
           Version: 4.3.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: davejmurphy at me dot com
 GCC build triplet: i386-apple-darwin9.6.0
  GCC host triplet: i386-apple-darwin9.6.0
GCC target triplet: arm-none-eabi


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


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

end of thread, other threads:[~2022-10-14 10:00 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-38644-4@http.gcc.gnu.org/bugzilla/>
2010-09-30 19:16 ` [Bug rtl-optimization/38644] [4.3/4.4/4.5/4.6 Regression] Optimization flag -O1 -fschedule-insns2 causes wrong code sebastian.huber@embedded-brains.de
2011-01-31 21:50 ` joel at gcc dot gnu.org
2011-02-07 16:39 ` law at redhat dot com
2011-04-26 15:16 ` [Bug rtl-optimization/38644] [4.3/4.4/4.5/4.6/4.7 " jiangning.liu at arm dot com
2011-06-27 14:30 ` rguenth at gcc dot gnu.org
2011-08-04 12:35 ` [Bug rtl-optimization/38644] [4.4/4.5/4.6/4.7 " sebastian.huber@embedded-brains.de
2011-08-05  4:00 ` ramana.r at gmail dot com
2011-08-05  6:50 ` sebastian.huber@embedded-brains.de
2011-08-09  2:08 ` jiangning.liu at arm dot com
2011-08-15  8:09 ` lingyouzeng@arimacomm-hz.cn
2011-09-06  7:46 ` sebastian.huber@embedded-brains.de
2011-09-09 13:48 ` joel at gcc dot gnu.org
2011-09-11 15:47 ` steven at gcc dot gnu.org
2011-09-12  8:48 ` sebastian.huber@embedded-brains.de
2011-09-12 15:32 ` law at redhat dot com
2011-09-12 15:37 ` rearnsha at arm dot com
2011-09-12 15:50 ` law at redhat dot com
2011-09-12 18:40 ` steven at gcc dot gnu.org
2011-09-26  8:11 ` rguenther at suse dot de
2011-10-15  8:49 ` sebastian.huber@embedded-brains.de
2011-10-24 13:09 ` sebastian.huber@embedded-brains.de
2011-10-28  7:34 ` sebastian.huber@embedded-brains.de
2011-10-29 23:29 ` davem at devkitpro dot org
2011-10-31  7:52 ` jiangning.liu at arm dot com
2011-10-31  8:34 ` mikpe at it dot uu.se
2011-10-31 10:46 ` sebastian.huber@embedded-brains.de
2011-11-04 16:53 ` jye2 at gcc dot gnu.org
2011-11-09  9:17 ` [Bug rtl-optimization/38644] [4.4/4.5/4.6 " sebastian.huber@embedded-brains.de
2011-11-16 10:33 ` liujiangning at gcc dot gnu.org
2012-01-09 16:58 ` ramana at gcc dot gnu.org
2012-03-13 14:55 ` [Bug rtl-optimization/38644] [4.5/4.6 " jakub at gcc dot gnu.org
2012-07-02 11:35 ` rguenth at gcc dot gnu.org
2012-07-31 16:29 ` [Bug rtl-optimization/38644] [4.6 " hagayg at broadcom dot com
2012-07-31 16:53 ` pinskia at gcc dot gnu.org
2012-07-31 17:37 ` hagayg at broadcom dot com
2013-04-05  3:51 ` peter at axium dot co.nz
2013-04-05  4:23 ` pinskia at gcc dot gnu.org
2013-04-05  7:15 ` sebastian.huber@embedded-brains.de
2014-02-16 10:01 ` jackie.rosen at hushmail dot com
2022-10-14  9:56 ` cvs-commit at gcc dot gnu.org
2022-10-14  9:57 ` cvs-commit at gcc dot gnu.org
2022-10-14  9:58 ` cvs-commit at gcc dot gnu.org
2022-10-14 10:00 ` cvs-commit at gcc dot gnu.org
2008-12-27 22:11 [Bug c/38644] New: " davejmurphy at me dot com
2010-08-12 10:00 ` [Bug rtl-optimization/38644] [4.3/4.4/4.5/4.6 Regression] " steven at gcc dot gnu dot org
2010-08-12 10:01 ` steven at gcc dot gnu dot org
2010-08-12 10:08 ` steven at gcc dot gnu dot org
2010-08-12 10:12 ` amonakov at gcc dot gnu dot org
2010-08-12 11:37 ` steven at gcc dot gnu dot org
2010-08-12 11:48 ` jakub at gcc dot gnu dot org
2010-08-12 12:00 ` amonakov at gcc dot gnu dot org
2010-08-12 12:04 ` rguenth at gcc dot gnu dot org
2010-08-12 12:13 ` rearnsha at gcc dot gnu dot org
2010-08-12 12:26 ` jakub at gcc dot gnu dot org
2010-08-12 12:31 ` rearnsha at gcc dot gnu dot org
2010-08-30 15:48 ` rguenth at gcc dot gnu dot org
2010-08-30 18:59 ` mikpe at it dot uu dot se

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