Bug 15782 - [3.4 only] m68k_output_mi_thunk emits wrong code for ColdFire
Summary: [3.4 only] m68k_output_mi_thunk emits wrong code for ColdFire
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.0
: P2 normal
Target Milestone: 3.4.1
Assignee: Bernardo Innocenti
Keywords: patch, wrong-code
Depends on:
Reported: 2004-06-02 20:25 UTC by Peter Barada
Modified: 2004-06-03 04:04 UTC (History)
2 users (show)

See Also:
Target: m68k-elf
Known to work:
Known to fail:
Last reconfirmed: 2004-06-02 20:29:31


Note You need to log in before you can comment on or make changes to this bug.
Description Peter Barada 2004-06-02 20:25:08 UTC
m68k_output_mi_thunk generats an adjustment of the first parameter on the stack
and calls off to the target function.  This adjustment is done using addq/subq
for values in the range of 1-8, but fo values outside that range, it generates
'add.l #<imm>,4(%sp)' which is valid for m68k, but invalid for ColdFire.  The
suggested fix for ColdFire is to load the value into %d0, and *then* emit 'add.l

The following code triggers this bug when compiled with:

m68k-elf-g++ -m5307 -O

     class FooA {
       virtual ~FooA () = 0;
       int data[100];

     class FooB {
       virtual void foo1 () = 0;
               void fooB () {foo1 ();}
       int data[100];

     class FooC : public FooA, public FooB {
       virtual void foo1 () {}

     FooC* Test ()
       FooC* foc = new FooC;
       foc->fooB ();
Comment 1 Andrew Pinski 2004-06-02 20:29:30 UTC
Confirmed, patch is around somewhere, I cannot find it right now (but I am not trying too hard).
Comment 2 Peter Barada 2004-06-02 20:32:54 UTC
The patch for this can be found at:

Comment 3 Mark Mitchell 2004-06-03 03:45:19 UTC
OK for 3 4.1.
Comment 4 CVS Commits 2004-06-03 04:03:01 UTC
Subject: Bug 15782

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	bernie@gcc.gnu.org	2004-06-03 04:02:49

Modified files:
	gcc            : ChangeLog 
	gcc/config/m68k: m68k.c 

Log message:
	PR target/15782
	* config/m68k/m68k.c(m68k_output_mi_thunk):  For ColdFire, use %d0 as
	a scratch to perform an add to memory.


Comment 5 Bernardo Innocenti 2004-06-03 04:04:41 UTC
Patch installed in both mailine and gcc-3_4-branch.