public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/47192] New: m68k target - gcc uses stack frame after it has been unlinked when compiling with -Os
@ 2011-01-06 15:56 tda at ls83 dot eclipse.co.uk
  2011-01-06 19:38 ` [Bug target/47192] " mikpe at it dot uu.se
  0 siblings, 1 reply; 2+ messages in thread
From: tda at ls83 dot eclipse.co.uk @ 2011-01-06 15:56 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: m68k target - gcc uses stack frame after it has been
                    unlinked when compiling with -Os
           Product: gcc
           Version: 4.5.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: tda@ls83.eclipse.co.uk


Created attachment 22913
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=22913
Testcase - Preprocessor output

Attached test case produces code which ends with 

  61 003c 41EE FFFE         lea (-2,%fp),%a0
  30:gcc-bug.c     ****   return d;
  31:gcc-bug.c     **** }
  62                       .loc 1 32 0
  63 0040 242E FFF8         move.l -8(%fp),%d2
  64 0044 4E5E              unlk %fp
  30:gcc-bug.c     ****   return d;
  65                       .loc 1 30 0
  66 0046 33D0 0000         move.w (%a0),stc.1197
  66      0000 
  67                       .loc 1 32 0
  68 004c 4E75              rts

If an interrupt occurs between the unlk and move.w, the variable pointed to by
(a0) is corrupted prior to being copied.

Compiling with -O1 keeps the lea and move.w together before the unlk, which is
correct.

Compiling with -O2 results in a move.w d1,stc.1197 after the unlk (contents of
variable already in d1), so gets away with it.

gcc output below and .i file attached.

Problem also present in 4.5.1.



m68k-elf-gcc -v -save-temps -c -g -gdwarf-2 -ffunction-sections -fdata-sections
-Os -mcpu=51qe -Wall -Wa,-ahlms=gcc-bug.ls -I.
-I/usr/local/gcc-m68k/m68k-elf/include gcc-bug.c
Using built-in specs.
COLLECT_GCC=m68k-elf-gcc
COLLECT_LTO_WRAPPER=/usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/4.5.2/lto-wrapper
Target: m68k-elf
Configured with: ../configure --target=m68k-elf
--prefix=/usr/local/gcc-m68k-4.5.2 --enable-languages=c --with-newlib
--disable-libssp --with-gnu-as --with-gnu-ld
Thread model: single
gcc version 4.5.2 (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-gdwarf-2'
'-ffunction-sections' '-fdata-sections' '-Os' '-mcpu=51qe' '-Wall' '-I.'
'-I/usr/local/gcc-m68k/m68k-elf/include'
 /usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/4.5.2/cc1 -E -quiet -v -I.
-I/usr/local/gcc-m68k/m68k-elf/include -imultilib m51qe gcc-bug.c -mcpu=51qe
-Wall -ffunction-sections -fdata-sections -g -gdwarf-2 -fworking-directory -Os
-fpch-preprocess -o gcc-bug.i
ignoring nonexistent directory
"/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/sys-include"
#include "..." search starts here:
#include <...> search starts here:
 .
 /usr/local/gcc-m68k/m68k-elf/include
 /usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/include
 /usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/include-fixed
 /usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-gdwarf-2'
'-ffunction-sections' '-fdata-sections' '-Os' '-mcpu=51qe' '-Wall' '-I.'
'-I/usr/local/gcc-m68k/m68k-elf/include'
 /usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/4.5.2/cc1 -fpreprocessed
gcc-bug.i -quiet -dumpbase gcc-bug.c -mcpu=51qe -auxbase gcc-bug -g -gdwarf-2
-Os -Wall -version -ffunction-sections -fdata-sections -o gcc-bug.s
GNU C (GCC) version 4.5.2 (m68k-elf)
    compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1, MPC
version 0.8.2
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64520
GNU C (GCC) version 4.5.2 (m68k-elf)
    compiled by GNU C version 4.3.2, GMP version 4.2.2, MPFR version 2.3.1, MPC
version 0.8.2
GGC heuristics: --param ggc-min-expand=64 --param ggc-min-heapsize=64520
Compiler executable checksum: 2edb184913810d520b23104a9f78d5ce
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-gdwarf-2'
'-ffunction-sections' '-fdata-sections' '-Os' '-mcpu=51qe' '-Wall' '-I.'
'-I/usr/local/gcc-m68k/m68k-elf/include'
 /usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/bin/as
-v -I. -I/usr/local/gcc-m68k/m68k-elf/include -mcpu=51qe -ahlms=gcc-bug.ls -o
gcc-bug.o gcc-bug.s
GNU assembler version 2.20 (m68k-elf) using BFD version (GNU Binutils) 2.20
COMPILER_PATH=/usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/4.5.2/:/usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/4.5.2/:/usr/local/gcc-m68k-4.5.2/libexec/gcc/m68k-elf/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/bin/
LIBRARY_PATH=/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/m51qe/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/lib/m51qe/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/:/usr/local/gcc-m68k-4.5.2/lib/gcc/m68k-elf/4.5.2/../../../../m68k-elf/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-c' '-g' '-gdwarf-2'
'-ffunction-sections' '-fdata-sections' '-Os' '-mcpu=51qe' '-Wall' '-I.'
'-I/usr/local/gcc-m68k/m68k-elf/include'


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

* [Bug target/47192] m68k target - gcc uses stack frame after it has been unlinked when compiling with -Os
  2011-01-06 15:56 [Bug target/47192] New: m68k target - gcc uses stack frame after it has been unlinked when compiling with -Os tda at ls83 dot eclipse.co.uk
@ 2011-01-06 19:38 ` mikpe at it dot uu.se
  0 siblings, 0 replies; 2+ messages in thread
From: mikpe at it dot uu.se @ 2011-01-06 19:38 UTC (permalink / raw)
  To: gcc-bugs

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

Mikael Pettersson <mikpe at it dot uu.se> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mikpe at it dot uu.se

--- Comment #1 from Mikael Pettersson <mikpe at it dot uu.se> 2011-01-06 19:19:21 UTC ---
I can reproduce this with both 4.5.2 and 4.4.6 based crosses to
m68k-{elf,linux}.
The -mcpu=51qe option seems to cause mis-scheduling of the epilogue.

With -Os -S -mcpu=51qe:

.L3:
        lea (-2,%fp),%a0
        move.l -8(%fp),%d2
        unlk %fp
        move.w (%a0),stc.1197
        rts

Without the -mcpu= option:

.L3:
        move.w -2(%fp),stc.1199
        move.l -8(%fp),%d2
        unlk %fp
        rts


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

end of thread, other threads:[~2011-01-06 19:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-06 15:56 [Bug target/47192] New: m68k target - gcc uses stack frame after it has been unlinked when compiling with -Os tda at ls83 dot eclipse.co.uk
2011-01-06 19:38 ` [Bug target/47192] " mikpe at it dot uu.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).