From 1ad663a82a1fe4993ac63ca028477916dd9535f1 Mon Sep 17 00:00:00 2001 From: Martin Jambor Date: Mon, 8 Aug 2011 19:53:55 +0200 Subject: [PATCH] re PR middle-end/49923 (__attribute__((packed)) on ARM is sometimes dropped) 2011-08-08 Martin Jambor 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. From-SVN: r177572 --- gcc/ChangeLog | 6 +++ gcc/testsuite/ChangeLog | 5 +++ gcc/testsuite/gcc.dg/tree-ssa/pr49923.c | 55 +++++++++++++++++++++++++ gcc/tree-sra.c | 3 ++ 4 files changed, 69 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/pr49923.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b1776f59f48..fc23fcb4a40 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2011-08-08 Martin Jambor + + PR middle-end/49923 + * tree-sra.c (access_precludes_ipa_sra_p): Also check access + memory alignment. + 2011-08-08 Diego Novillo * Makefile.in (LTO_STREAMER_H): Add DIAGNOSTIC_H. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4ce23b79764..347975d7091 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2011-08-08 Martin Jambor + + PR middle-end/49923 + * gcc.dg/tree-ssa/pr49923.c: New test. + 2011-08-08 H.J. Lu PR target/49781 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr49923.c b/gcc/testsuite/gcc.dg/tree-ssa/pr49923.c new file mode 100644 index 00000000000..83113f815fd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr49923.c @@ -0,0 +1,55 @@ +/* { dg-do run } */ +/* { dg-options "-O3" } */ + +#define PACKED __attribute__(( packed )) + +struct PACKED aostk_point_u8 { + unsigned char x; + unsigned char y; +}; + +struct PACKED aostk_size_u8 { + unsigned char width; + unsigned char height; +}; + +struct PACKED aostk_glyph { + unsigned short i; + struct aostk_size_u8 size; + char top; + struct aostk_point_u8 advance; + unsigned char pitch; + unsigned char* data; + char left; +}; + + +struct PACKED aostk_font { + unsigned short numglyphs; + unsigned char height; + struct aostk_glyph* glyphs; +}; + +struct aostk_font glob_font; + +static struct aostk_glyph* aostk_get_glyph(struct aostk_font* f, unsigned int c) { + return f->glyphs; +} + +int aostk_font_strwidth(struct aostk_font* font, const char* str) { + struct aostk_glyph* g = aostk_get_glyph(font, 0); + return (g != 0); +} + +struct aostk_font* +__attribute__ ((noinline, noclone)) +get_some_font (void) +{ + return &glob_font; +} + +int main (int argc, char *argv[]) +{ + return (int) aostk_font_strwidth (get_some_font (), "sth"); + +} diff --git a/gcc/tree-sra.c b/gcc/tree-sra.c index cc5cd36123f..ab60748c970 100644 --- a/gcc/tree-sra.c +++ b/gcc/tree-sra.c @@ -3688,6 +3688,9 @@ access_precludes_ipa_sra_p (struct access *access) || gimple_code (access->stmt) == GIMPLE_ASM)) return true; + if (tree_non_mode_aligned_mem_p (access->expr)) + return true; + return false; } -- 2.30.2