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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  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 ` sgh at sgh dot dk
  2011-08-02 12:19 ` sgh at sgh dot dk
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-07-31 15:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #1 from Søren Holm <sgh at sgh dot dk> 2011-07-31 15:16:21 UTC ---
Created attachment 24878
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=24878
Test that generates wrong aligned ldr


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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  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
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-02 12:19 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Søren Holm <sgh at sgh dot dk> 2011-08-02 12:19:15 UTC ---
Martin, do you have an idea as to was is wrong ?


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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  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
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: rguenth at gcc dot gnu.org @ 2011-08-02 13:13 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Richard Guenther <rguenth at gcc dot gnu.org> 2011-08-02 13:11:40 UTC ---
It's easy - misaligned accesses on strict-align targets are a PITA.  IPA-SRA
needs similar adjustments as scalar SRA to keep memory references in
the component-ref style form which is the only one that the expander "properly"
handles.


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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (2 preceding siblings ...)
  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
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-02 13:27 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Søren Holm <sgh at sgh dot dk> 2011-08-02 13:26:25 UTC ---
Adding -fno-ipa-sra makes gcc behave correct. Can it be fixed for 4.6.2 ?


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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (3 preceding siblings ...)
  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
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-03 17:40 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #5 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-03 17:39:05 UTC ---
Søren, can you please verify this patch fixes the problem for you?
It's based on trunk but should apply well to the 4.6 branch too.
Thanks.

Index: src/gcc/tree-sra.c
===================================================================
--- src.orig/gcc/tree-sra.c
+++ src/gcc/tree-sra.c
@@ -3688,6 +3688,9 @@ access_precludes_ipa_sra_p (struct acces
       || gimple_code (access->stmt) == GIMPLE_ASM))
     return true;

+  if (tree_non_mode_aligned_mem_p (access->expr))
+    return true;
+
   return false;
 }


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

* [Bug c/49923] __attirubte__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (4 preceding siblings ...)
  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
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-03 21:00 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Søren Holm <sgh at sgh dot dk> 2011-08-03 21:00:06 UTC ---
As  far as my isolated test-case goes the patch works. :D
I will report back after a test on the target tomorrow.


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

* [Bug c/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (5 preceding siblings ...)
  2011-08-03 21:00 ` sgh at sgh dot dk
@ 2011-08-04  8:01 ` sgh at sgh dot dk
  2011-08-05 15:19 ` [Bug middle-end/49923] " jamborm at gcc dot gnu.org
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-04  8:01 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Søren Holm <sgh at sgh dot dk> 2011-08-04 08:00:14 UTC ---
It works on the target too. From my perspective your patch fixes this issue.

Thank you very much Martin.


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (6 preceding siblings ...)
  2011-08-04  8:01 ` [Bug c/49923] __attribute__((packed)) " sgh at sgh dot dk
@ 2011-08-05 15:19 ` jamborm at gcc dot gnu.org
  2011-08-08 17:54 ` jamborm at gcc dot gnu.org
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-05 15:19 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2011.08.05 15:18:52
         AssignedTo|unassigned at gcc dot       |jamborm at gcc dot gnu.org
                   |gnu.org                     |
     Ever Confirmed|0                           |1

--- Comment #8 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-05 15:18:52 UTC ---
Patch posted to the mailing list:

http://gcc.gnu.org/ml/gcc-patches/2011-08/msg00606.html


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (7 preceding siblings ...)
  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
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-08 17:54 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #9 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-08 17:53:57 UTC ---
Author: jamborm
Date: Mon Aug  8 17:53:55 2011
New Revision: 177572

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177572
Log:
2011-08-08  Martin Jambor  <mjambor@suse.cz>

    PR middle-end/49923
    * tree-sra.c (access_precludes_ipa_sra_p): Also check access
    memory alignment.

    * testsuite/gcc.dg/tree-ssa/pr49923.c: New test.


Added:
    trunk/gcc/testsuite/gcc.dg/tree-ssa/pr49923.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/tree-sra.c


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (8 preceding siblings ...)
  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
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-09  6:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #10 from Søren Holm <sgh at sgh dot dk> 2011-08-09 06:37:41 UTC ---
Sweet, but why is it not applied to gcc-4_6-branch ?


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (9 preceding siblings ...)
  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
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-09  7:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #11 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-09 07:16:06 UTC ---
(In reply to comment #10)
> Sweet, but why is it not applied to gcc-4_6-branch ?

Because I have started the final bootstrap and test on the branch only a few
minutes ago.  If it succeeds (and it certainly should), I will apply it later
today.


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (10 preceding siblings ...)
  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
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-09  7:38 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #12 from Søren Holm <sgh at sgh dot dk> 2011-08-09 07:37:30 UTC ---
Great. I asked because other bugfixes has been commited both places in a single
commit. :)


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (11 preceding siblings ...)
  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
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-09 16:33 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #13 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-09 16:33:01 UTC ---
Author: jamborm
Date: Tue Aug  9 16:32:59 2011
New Revision: 177604

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=177604
Log:
2011-08-09  Martin Jambor  <mjambor@suse.cz>

    PR middle-end/49923
    * tree-sra.c (access_precludes_ipa_sra_p): Also check access
    memory alignment.

    * testsuite/gcc.dg/tree-ssa/pr49923.c: New test.


Added:
    branches/gcc-4_6-branch/gcc/testsuite/gcc.dg/tree-ssa/pr49923.c
Modified:
    branches/gcc-4_6-branch/gcc/ChangeLog
    branches/gcc-4_6-branch/gcc/testsuite/ChangeLog
    branches/gcc-4_6-branch/gcc/tree-sra.c


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (12 preceding siblings ...)
  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
  14 siblings, 0 replies; 16+ messages in thread
From: jamborm at gcc dot gnu.org @ 2011-08-09 17:04 UTC (permalink / raw)
  To: gcc-bugs

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

Martin Jambor <jamborm at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED

--- Comment #14 from Martin Jambor <jamborm at gcc dot gnu.org> 2011-08-09 17:03:30 UTC ---
Fixed.


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

* [Bug middle-end/49923] __attribute__((packed)) on ARM is sometimes dropped
  2011-07-31 15:15 [Bug c/49923] New: __attirubte__((packed)) on ARM is sometimes dropped sgh at sgh dot dk
                   ` (13 preceding siblings ...)
  2011-08-09 17:04 ` jamborm at gcc dot gnu.org
@ 2011-08-09 17:20 ` sgh at sgh dot dk
  14 siblings, 0 replies; 16+ messages in thread
From: sgh at sgh dot dk @ 2011-08-09 17:20 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #15 from Søren Holm <sgh at sgh dot dk> 2011-08-09 17:19:06 UTC ---
Sweet. Thanks Martin :)


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