public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Thomas Martitz <thomas.martitz@student.HTW-Berlin.de>
To: gcc-help@gcc.gnu.org
Subject: Re: Problems migrating to gcc 4.4.3&eabi  - apparently a gcc bug
Date: Tue, 09 Mar 2010 19:11:00 -0000	[thread overview]
Message-ID: <4B969D5F.6080501@htw-berlin.de> (raw)
In-Reply-To: <4B96994D.40904@htw-berlin.de>

Am 09.03.2010 19:54, schrieb Thomas Martitz:
> Am 09.03.2010 19:36, schrieb Andrew Haley:
>> That does not surprise me.  I think you're seeing a problem that is
>> caused by something elsewhere in your program.  I'm guessing that
>> there may be a bad prototype or somesuch.
>>
>> I think you need to strip down your sources until you find something.
>>
>> Maybe you should try -save-temps and have a look at the actual
>> preprocessd source.  Maybe some bastard has done
>>
>> #define int long
>>
>> or something evil like that!
>>
>> Andrew.
>
> No, I know our codebase pretty well. This is not the problem. Not that 
> int or long matters, anyway.
>
> In the mean time we found a test case:
>
> ----
> void foo(int last, char * block);
>
> void bar(void)
> {
>     struct {
>         char * __attribute__((aligned(8))) member;
>     } s;
>
>     foo(0,s.member);
> }
> ----
>
> compiled with arm-elf-eabi-gcc -c test.c
>
> This example exposes the problem.
>
> We found the problem is related to struct addressing and the aligned 
> attribute.
>
> - normal stack variables work
> - struct members work with __attribute__((aligned(4)))
> - struct members with __attribute__((aligned(X))) where X >= 8 *do 
> not* work.
>
> Look at the assembly output for this very example. block is passed in 
> r2, while it's supposed to be passed in r1.
>
> Our temporary "fix" is to make it "void foo(int last, volatile char * 
> block);" [notice the volatile keyword] and it works as well (block 
> passed in r1).
>
> This is definitely a gcc bug. The generated call is dependent on the 
> parameter passed. The callee can't know about this. And it also 
> happens with -O0.
>
>
> Best regards.

A bit more on this issue.

In the rockbox code, this struct member caused the behavior:

     int16_t * ATTR_ALIGN(16) DCTblock;  /* put buffer separately to 
have it in IRAM */

Actually we don't need the pointer to be 16byte aligned, but the buffer 
it points to. Hence, removing the ATTR_ALIGN(16) (a #define for 
__attribute__((aligned(X)) ) works for us.

Nevertheless, it is a gcc bug. It seems likely that gcc confuses 
something here 64bit values must be 8byte aligned afaik. On ARM EABI, 
64bit types need to be passed into an even (and the next odd, e.g. r2 
and r3) registers. Maybe now treats all 8+ byte aligned data as 64bit, 
which would explain why it wants to put normal 32bit into even 
registers, which violates the calling convention.

Best regards.

  reply	other threads:[~2010-03-09 19:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-03-09 16:31 Thomas Martitz
2010-03-09 16:42 ` Andrew Haley
2010-03-09 17:11   ` Thomas Martitz
2010-03-09 18:36     ` Andrew Haley
2010-03-09 18:54       ` Thomas Martitz
2010-03-09 19:11         ` Thomas Martitz [this message]
2010-03-09 19:39           ` John (Eljay) Love-Jensen
2010-03-09 19:44             ` Thomas Martitz
2010-03-09 19:46         ` Andrew Haley
2010-03-10 15:56           ` Ian Lance Taylor
2010-03-10 16:36             ` Thomas Martitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B969D5F.6080501@htw-berlin.de \
    --to=thomas.martitz@student.htw-berlin.de \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).