Try compiling code below with h8300-coff-gcc -fomit-frame-pointer -mh -mn bug.c ================================================== void foo(int a, int b, int c, int d) { } void bar ( char a, char b ) { } void main(void) { char a ; foo(1,2,3,4); a = 10; bar(a, 1); printf("a=%d\n", a); } ================================================== h8300-hms-run a.out prints a=244 If you see the generated assembly, variable a is accessed using -ve offset from SP. It should be +ve offset. mov.b r2l,@(-1,er7) ;# a The problem doesn't appear if line calling function foo() is commented. I think this is related to INITIAL_ELIMINATION_OFFSET. -Dhananjay
Confirmed with gcc-3.4 20031121.
Reduced to: void foo (int, int, int, int); char bar (void) { char a; foo (0, 0, 0, 0); a = 10; return a; }
Probably the following better describes the problem. You get a positive (correct) offset for "a = 10;" and a negative one for "return a;". So I doubt the problem is related to INITIAL_ELIMINATION_OFFSET. void foo (int, int, int, int); short bar (void) { short a = 10; foo (0, 0, 0, 0); return a; }
OK. I've got a patch and am testing it now.
Fixed with http://gcc.gnu.org/ml/gcc-patches/2003-11/msg01894.html http://gcc.gnu.org/ml/gcc-cvs/2003-11/msg00701.html
Subject: RE: h8300 - local variable gets corrupted by function call when -fomit-frame-pointer is given Thanks Kazu. This PR can be closed. -Dhananjay
Subject: Bug 13122 CVSROOT: /cvs/gcc Module name: gcc Branch: gcc-3_3-branch Changes by: kazu@gcc.gnu.org 2003-12-15 20:24:33 Modified files: gcc : ChangeLog gcc/config/h8300: h8300.c h8300.h h8300.md lib1funcs.asm Log message: PR target/13122 * config/h8300/h8300.md (pushqi1_h8300hs_normal): New. (pushqi1): Call gen_pushqi1_h8300hs_normal in normal mode. (pushhi1_h8300hs_normal): New. (pushhi1): Call gen_pushqi1_h8300hs_normal in normal mode. * config/h8300/h8300.h (LINK_SPEC): Support normal mode. * config/h8300/h8300.c (asm_file_start): Correctly output an architecture directive. * config/h8300/lib1funcs.asm: Correctly specify an architecture directive. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.843&r2=1.16114.2.844 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/h8300/h8300.c.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.174.2.4&r2=1.174.2.5 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/h8300/h8300.h.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.123.2.1&r2=1.123.2.2 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/h8300/h8300.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.123.2.6&r2=1.123.2.7 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/h8300/lib1funcs.asm.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16&r2=1.16.4.1
Fixed for 3.3.3.