public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "will_lentz at trimble dot com" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug target/49094] New: ARM aligned(1) attribute is sometimes dropped
Date: Fri, 20 May 2011 22:20:00 -0000	[thread overview]
Message-ID: <bug-49094-4@http.gcc.gnu.org/bugzilla/> (raw)

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


             reply	other threads:[~2011-05-20 22:15 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-20 22:20 will_lentz at trimble dot com [this message]
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

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=bug-49094-4@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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).