public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/49094] New: ARM aligned(1) attribute is sometimes dropped
@ 2011-05-20 22:20 will_lentz at trimble dot com
  2011-05-31 22:20 ` [Bug target/49094] " ramana at gcc dot gnu.org
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: will_lentz at trimble dot com @ 2011-05-20 22:20 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49094

           Summary: ARM aligned(1) attribute is sometimes dropped
           Product: gcc
           Version: 4.6.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: target
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: will_lentz@trimble.com


Created attachment 24313
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24313
simple test case to demonstrate problem

GCC 4.6.0 sometimes produces unaligned accesses for structures with
__attribute__((aligned(1),packed)).  GCC 4.4.1 seems fine.

See the attached "tst.c" file.  GCC 4.6.0 will access an unaligned ip->ip_dst
with "ldr" instead of several "ldrb" instructions.

The file can be compiled and examined with:
  arm-none-eabi-gcc -c  -g -Os tst.c
  arm-none-eabi-objdump -S tst.o

*********
GCC 4.6.0 produces:
Disassembly of section .text:

00000000 <test_alignment>:
{
  struct ip *ip = (struct ip *)m;
  struct in_addr pkt_dst;
  pkt_dst = ip->ip_dst ;
  if( pkt_dst.s_addr == 0 )
    return 1;
   0:   e5900007        ldr     r0, [r0, #7]
  else
    return 0;
}
   4:   e2700001        rsbs    r0, r0, #1
   8:   33a00000        movcc   r0, #0
   c:   e12fff1e        bx      lr


*********
GCC 4.4.1 produces:
Disassembly of section .text:

00000000 <test_alignment>:
} __attribute__ ((aligned(1), packed));

struct ip *ip_fw_fwd_addr;

int test_alignment( char *m )
{
   0:   e5d02008        ldrb    r2, [r0, #8]
   4:   e5d03007        ldrb    r3, [r0, #7]
   8:   e5d01009        ldrb    r1, [r0, #9]
   c:   e1833402        orr     r3, r3, r2, lsl #8
  10:   e5d0200a        ldrb    r2, [r0, #10]
  14:   e1833801        orr     r3, r3, r1, lsl #16
  18:   e1932c02        orrs    r2, r3, r2, lsl #24
  pkt_dst = ip->ip_dst ;
  if( pkt_dst.s_addr == 0 )
    return 1;
  else
    return 0;
}
  1c:   13a00000        movne   r0, #0  ; 0x0
  20:   03a00001        moveq   r0, #1  ; 0x1
  24:   e12fff1e        bx      lr


^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-07-31 15:19 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-20 22:20 [Bug target/49094] New: ARM aligned(1) attribute is sometimes dropped will_lentz at trimble dot com
2011-05-31 22:20 ` [Bug target/49094] " ramana at gcc dot gnu.org
2011-06-05 21:52 ` mikpe at it dot uu.se
2011-06-11 19:13 ` jamborm at gcc dot gnu.org
2011-06-11 23:10 ` jamborm at gcc dot gnu.org
2011-06-26 18:25 ` [Bug tree-optimization/49094] " jamborm at gcc dot gnu.org
2011-06-30 13:25 ` jamborm at gcc dot gnu.org
2011-07-11 16:31 ` will_lentz at trimble dot com
2011-07-11 16:55 ` jamborm at gcc dot gnu.org
2011-07-11 17:37 ` jamborm at gcc dot gnu.org
2011-07-30 12:12 ` sgh at sgh dot dk
2011-07-30 12:14 ` sgh at sgh dot dk
2011-07-30 12:30 ` sgh at sgh dot dk
2011-07-30 12:39 ` sgh at sgh dot dk
2011-07-30 17:16 ` jamborm at gcc dot gnu.org
2011-07-31 15:19 ` sgh at sgh dot dk

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).