[PATCH, ARM] Unaligned accesses for packed structures [1/2]

Joseph S. Myers joseph@codesourcery.com
Thu Aug 25 22:23:00 GMT 2011


On Thu, 25 Aug 2011, Ramana Radhakrishnan wrote:

> On 25 August 2011 18:31, Julian Brown <julian@codesourcery.com> wrote:
> > On Thu, 25 Aug 2011 16:46:50 +0100
> > Julian Brown <julian@codesourcery.com> wrote:
> >
> >> So, OK to apply this version, assuming testing comes out OK? (And the
> >> followup patch [2/2], which remains unchanged?)
> >
> > FWIW, all tests pass, apart from gcc.target/arm/volatile-bitfields-3.c,
> > which regresses. The output contains:
> >
> >        ldrh    r0, [r3, #2]    @ unaligned
> >
> > I believe that, to conform to the ARM EABI, that GCC must use an
> > (aligned) ldr in this case. Is that correct?
> 
> That is correct by my reading of the ABI Spec.
> 
> The relevant section is 7.1.7.5 where it states that :
> 
> "When a volatile bitfield is read it's container must be read exactly
> once using the access width appropriate to the type of the container.
> "
> 
> Here the type of the container is a long and hence the access should
> be with an ldr instruction followed by a shift as it is today
> irrespective whether we support unaligned accesses in this case.

Except for packed structures, anyway (and there aren't any packed 
structures involved in this particular testcase).  The ABI doesn't cover 
packed structures and I maintain that there the target-independent GNU C 
semantics take precedence - meaning that if the compiler doesn't know that 
a single read with the relevant access width is going to be safe, it must 
use an instruction sequence it does know to be safe.

-- 
Joseph S. Myers
joseph@codesourcery.com


More information about the Gcc-patches mailing list