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

             Bug #: 53386
           Summary: Bad assembly code produced for m68000
    Classification: Unclassified
           Product: gcc
           Version: 4.6.4
            Status: UNCONFIRMED
          Severity: blocker
          Priority: P3
         Component: target
        AssignedTo: unassig...@gcc.gnu.org
        ReportedBy: lja...@gmail.com


Hi,

I'm currently using gcc 4.2.4 to build uClinux for a 68000 target (68HC000
cpu).

I've update my toolchain to newer tool versions but now gcc (4.6.4) is
producing bad assembly for this target.

I'm almost sure that it is producing only 68020 assembly code and/or ignoring
the -m68000 switch (I checked that when specifying -m68000 or -m68020 gcc is
producing the same assembly code).


Here is a simple testcase (a line from the kernel where my system was hanging):

C instruction (from 'proc_net_ns_init' function):

[...]
memcpy(netd->name, "net", 4);
[...]


4.2.4 assembly output:
[...]
  60:    157c 006e 004d     moveb #110,%a2@(77)
  66:    157c 0065 004e     moveb #101,%a2@(78)
  6c:    157c 0074 004f     moveb #116,%a2@(79)
  72:    422a 0050          clrb %a2@(80)
[...]


4.6.4 assembly output:
[...]
  42:    217c 6e65 7400     movel #1852142592,%a0@(77)
  48:    004d 
[...]


Since the opcode movel has an odd displacement, it is causing an address/bus
error exception, halting the cpu.



Another difference I've noticed while tracing the above issue, is the way
parameters are placed in the stack for the function call:


4.2.4 assembly:
[...]
movel  absolute_address,%sp-
[...]


4.6.4 assembly:
[...]
moveaw  value1,%a0
addal   value2,%a0
movel   %a0@,%sp-
[...]


This is not critical but at a first look, it look it has slower execution and
produces larger code (is this correct?).




Command line used in this test (from the kernel build):

m68k-uclinux-gcc -m68000 -Wp,-MD,net/sunrpc/.rpc_pipe.o.d -isystem
/usr/local/lib/gcc/m68k-uclinux/4.5.1/include
-I/root/m68k/20120401/uClinux-dist/linux-3.x/arch/m68k/include
-Iarch/m68k/include/generated -Iinclude  -include
/root/m68k/20120401/uClinux-dist/linux-3.x/include/linux/kconfig.h -D__KERNEL__
-Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing
-fno-common -Werror-implicit-function-declaration -Wno-format-security
-fno-delete-null-pointer-checks -O2 -pipe -DUTS_SYSNAME=\"uClinux\"
-D__uClinux__ -fomit-frame-pointer -Wdeclaration-after-statement
-Wno-pointer-sign -fno-strict-overflow -DCC_HAVE_ASM_GOTO   
-D"KBUILD_STR(s)=#s" -D"KBUILD_BASENAME=KBUILD_STR(rpc_pipe)" 
-D"KBUILD_MODNAME=KBUILD_STR(sunrpc)" -c -o fs/proc/proc_net.o
fs/proc/proc_net.c



Anyone knows what is the latest gcc version where code for 68000 is still ok?
(I didn't want to go and build version by version until I find the one that's
broken...)



Regards,
Luis Alves

Reply via email to