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: unassig...@gcc.gnu.org
        ReportedBy: s...@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  <mjam...@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

Reply via email to