From: Easwaran Raman Date: Wed, 20 Apr 2011 18:34:59 +0000 (+0000) Subject: cfgexpand.c (add_alias_set_conflicts): Add conflicts with a variable containing union... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a25752bbd26c53f9c1c821afcfaf4b92ccb0527;p=gcc.git cfgexpand.c (add_alias_set_conflicts): Add conflicts with a variable containing union type only with -fstrict-aliasing. 2011-04-20 Easwaran Raman * cfgexpand.c (add_alias_set_conflicts): Add conflicts with a variable containing union type only with -fstrict-aliasing. 2011-04-20 Easwaran Raman * gcc.dg/stack-layout-1.c: New test. From-SVN: r172788 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 86a2b832cf1..85ec2e60747 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,8 @@ +2011-04-20 Easwaran Raman + + * cfgexpand.c (add_alias_set_conflicts): Add conflicts with a variable + containing union type only with -fstrict-aliasing. + 2011-04-20 Jim Meyering Remove useless if-before-free tests. diff --git a/gcc/cfgexpand.c b/gcc/cfgexpand.c index a3abc8497df..e88bec14945 100644 --- a/gcc/cfgexpand.c +++ b/gcc/cfgexpand.c @@ -373,8 +373,9 @@ add_alias_set_conflicts (void) to elements will conflict. In case of unions we have to be careful as type based aliasing rules may say access to the same memory does not conflict. So play - safe and add a conflict in this case. */ - || contains_union) + safe and add a conflict in this case when + -fstrict-aliasing is used. */ + || (contains_union && flag_strict_aliasing)) add_stack_var_conflict (i, j); } } diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 3528f3e43c2..dfa5c8c00ce 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2011-04-20 Easwaran Raman + + * gcc.dg/stack-layout-1.c: New test. + 2011-04-20 Daniel Jacobowitz * gcc.dg/vect/vect-shift-3.c, gcc.dg/vect/vect-shift-4.c: New. diff --git a/gcc/testsuite/gcc.dg/stack-layout-1.c b/gcc/testsuite/gcc.dg/stack-layout-1.c new file mode 100644 index 00000000000..389a4eb051e --- /dev/null +++ b/gcc/testsuite/gcc.dg/stack-layout-1.c @@ -0,0 +1,25 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fno-strict-aliasing -fdump-rtl-expand" } */ +union U { + int a; + float b; +}; +struct A { + union U u1; + char a[100]; +}; +void bar (struct A *); +void foo () + { + { + struct A a; + bar (&a); + } + { + struct A a; + bar (&a); + } + } + +/* { dg-final { scan-rtl-dump-times "Partition" 1 "expand" } } */ +/* { dg-final { cleanup-rtl-dump "expand" } } */