public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped
@ 2011-07-31 15:15 sgh at sgh dot dk
  2011-07-31 15:16 ` [Bug c/49923] " sgh at sgh dot dk
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-07-31 15:15 UTC (permalink / raw)
  To: gcc-bugs

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

           Summary: __attirubte__((packed)) on ARM is sometimes dropped
           Product: gcc
           Version: 4.6.2
            Status: UNCONFIRMED
          Severity: major
          Priority: P3
         Component: c
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: sgh@sgh.dk


tst2.c fails with an alignment related problem.

With "static" on line 33 the code generated is this :

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
unsigned int aostk_font_strwidth(const struct aostk_font* font, const char*
str) {
        const struct aostk_glyph* g = aostk_get_glyph(font, 0);
        return g->advance.x;
   0:   e5903003        ldr     r3, [r0, #3]
}
   4:   e5d30005        ldrb    r0, [r3, #5]
   8:   e12fff1e        bx      lr
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

The first ldr-instruction is wrong afaik since struct aostk_font is packed.

Removing "static" fomr line 33 gives this code :

<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
const struct aostk_glyph* aostk_get_glyph(const struct aostk_font* f, unsigned
int c) {
        return &f->glyphs[0];
   0:   e5d02004        ldrb    r2, [r0, #4]
   4:   e5d03003        ldrb    r3, [r0, #3]
   8:   e1833402        orr     r3, r3, r2, lsl #8
   c:   e5d02005        ldrb    r2, [r0, #5]
  10:   e5d00006        ldrb    r0, [r0, #6]
  14:   e1833802        orr     r3, r3, r2, lsl #16
}
  18:   e1830c00        orr     r0, r3, r0, lsl #24
  1c:   e12fff1e        bx      lr

00000020 <aostk_font_strwidth>:
        const struct aostk_glyph* glyphs;
};


const struct aostk_glyph* aostk_get_glyph(const struct aostk_font* f, unsigned
int c) {
        return &f->glyphs[0];
  20:   e5d02004        ldrb    r2, [r0, #4]
  24:   e5d03003        ldrb    r3, [r0, #3]
  28:   e1833402        orr     r3, r3, r2, lsl #8
  2c:   e5d02005        ldrb    r2, [r0, #5]
  30:   e1833802        orr     r3, r3, r2, lsl #16
  34:   e5d02006        ldrb    r2, [r0, #6]
  38:   e1833c02        orr     r3, r3, r2, lsl #24


unsigned int aostk_font_strwidth(const struct aostk_font* font, const char*
str) {
        const struct aostk_glyph* g = aostk_get_glyph(font, 0);
        return g->advance.x;
}
  3c:   e5d30005        ldrb    r0, [r3, #5]
  40:   e12fff1e        bx      lr
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

Notice in aostk_get_glyph that the ldrb-instructions are used instead of ldr.

I compile using -Os, Compiling with -O0 generates correct code. Compiling with
-fno-tree-sra also generates wrong code.

I have bisected the problem and to this commit:

Author: jamborm <jamborm@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Sep 9 23:28:27 2010 +0000

    2010-09-10  Martin Jambor  <mjambor@suse.cz>

        PR tree-optimization/44972                                              
        * ipa-prop.c (ipa_modify_call_arguments): Build MEM_REF instead of      
        calling build_ref_for_offset.

        * testsuite/g++.dg/torture/pr34850.C: Remove expected warning.



    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164135
138bc75d-0d04-0410-961f-82ee72b054a4


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

end of thread, other threads:[~2011-08-09 17:20 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
2011-07-31 15:16 ` [Bug c/49923] " sgh at sgh dot dk
2011-08-02 12:19 ` sgh at sgh dot dk
2011-08-02 13:13 ` rguenth at gcc dot gnu.org
2011-08-02 13:27 ` sgh at sgh dot dk
2011-08-03 17:40 ` jamborm at gcc dot gnu.org
2011-08-03 21:00 ` sgh at sgh dot dk
2011-08-04  8:01 ` [Bug c/49923] __attribute__((packed)) " sgh at sgh dot dk
2011-08-05 15:19 ` [Bug middle-end/49923] " jamborm at gcc dot gnu.org
2011-08-08 17:54 ` jamborm at gcc dot gnu.org
2011-08-09  6:38 ` sgh at sgh dot dk
2011-08-09  7:16 ` jamborm at gcc dot gnu.org
2011-08-09  7:38 ` sgh at sgh dot dk
2011-08-09 16:33 ` jamborm at gcc dot gnu.org
2011-08-09 17:04 ` jamborm at gcc dot gnu.org
2011-08-09 17:20 ` 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).