Re: [arm-gnu] Optimization problems with ARM GCC 4.5.1 2010.09-50
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [arm-gnu] Optimization problems with ARM GCC 4.5.1 2010.09-50



On 12/21/2010 11:14 PM, Dirk Behme wrote:

> we found that it optimizes away all HW accesses declared with 'volatile'
> (see test code [1]):
> 
> 00000000 <main>:
>    0:    e3a00000     mov    r0, #0
>    4:    e12fff1e     bx    lr

I believe that this is a (now) known bug in GCC 4.5.1, independent of
architecture.  In particular, if the base object (struct gptimer) is not
declared volatile, then a cast to volatile in accessing its fields is
not sufficient to get the compiler to recognize the volatility.

The work-around is to declare the variable as:

  volatile struct gptimer *gpt1_base = (struct gptimer *)0x48318000;

I will file this as an internal issue, and would expect it will be fixed
in our Sprite Lite Edition release (and possibly sooner in our
commercial releases).

> In a routine accessing a NAND device, the compiler adds an additional
> "ldrb    r3, [r3]" which breaks the access to the NAND device (the HW
> forbids reading in this state):

I didn't see a complete test-case for this in your post.  But, as was
mentioned in a previous post, the value of a statement-expression is the
last expression therein, so it's quite likely that the read is coming
because the volatile access is the last thing in the statement-expression.

Thank you,

-- 
Mark Mitchell
CodeSourcery
mark@xxxxxxxxxxxxxxxx
(650) 331-3385 x713