Message ID | g4tybfnve8.fsf@linaro.org |
---|---|
State | New |
Headers | show |
On Fri, Jun 24, 2011 at 4:42 PM, Richard Sandiford <richard.sandiford@linaro.org> wrote: > This patch fixes PR 49169, where GCC is incorrectly optimising away > a test for whether a function is Thumb rather than ARM. The patch > was posted by Richard in the PR: > > http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49169 > > See the PR for a discussion about whether a target hook is better > (or not, IMO). > > Tested on arm-linux-gnueabi, where it fixes the attached testcase. > OK to install? Ok. Thanks, Richard. > Richard > > > gcc/ > 2011-07-24 Richard Guenther <rguenther@suse.de> > > PR tree-optimization/49169 > * fold-const.c (get_pointer_modulus_and_residue): Don't rely on > the alignment of function decls. > > gcc/testsuite/ > 2011-07-24 Michael Hope <michael.hope@linaro.org> > Richard Sandiford <richard.sandiford@linaro.org> > > PR tree-optimization/49169 > * gcc.dg/torture/pr49169.c: New test. > > Index: gcc/fold-const.c > =================================================================== > --- gcc/fold-const.c 2011-06-22 16:48:38.000000000 +0100 > +++ gcc/fold-const.c 2011-06-23 17:50:33.000000000 +0100 > @@ -9216,7 +9216,8 @@ get_pointer_modulus_and_residue (tree ex > *residue = 0; > > code = TREE_CODE (expr); > - if (code == ADDR_EXPR) > + if (code == ADDR_EXPR > + && TREE_CODE (TREE_OPERAND (expr, 0)) != FUNCTION_DECL) > { > unsigned int bitalign; > bitalign = get_object_alignment_1 (TREE_OPERAND (expr, 0), residue); > Index: gcc/testsuite/gcc.dg/torture/pr49169.c > =================================================================== > --- /dev/null 2011-06-20 08:31:41.268810499 +0100 > +++ gcc/testsuite/gcc.dg/torture/pr49169.c 2011-06-23 17:52:24.000000000 +0100 > @@ -0,0 +1,13 @@ > +#include <stdlib.h> > +#include <stdint.h> > + > +int > +main (void) > +{ > + void *p = main; > + if ((intptr_t) p & 1) > + abort (); > + return 0; > +} > + > +/* { dg-final { scan-assembler "abort" } } */ >
On Fri, Jun 24, 2011 at 8:50 AM, Richard Guenther <richard.guenther@gmail.com> wrote: > On Fri, Jun 24, 2011 at 4:42 PM, Richard Sandiford > <richard.sandiford@linaro.org> wrote: >> This patch fixes PR 49169, where GCC is incorrectly optimising away >> a test for whether a function is Thumb rather than ARM. The patch >> was posted by Richard in the PR: >> >> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49169 >> >> See the PR for a discussion about whether a target hook is better >> (or not, IMO). >> >> Tested on arm-linux-gnueabi, where it fixes the attached testcase. >> OK to install? > > Ok. > > Thanks, > Richard. > >> Richard >> >> >> gcc/ >> 2011-07-24 Richard Guenther <rguenther@suse.de> >> >> PR tree-optimization/49169 >> * fold-const.c (get_pointer_modulus_and_residue): Don't rely on >> the alignment of function decls. >> This caused: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49545
Index: gcc/fold-const.c =================================================================== --- gcc/fold-const.c 2011-06-22 16:48:38.000000000 +0100 +++ gcc/fold-const.c 2011-06-23 17:50:33.000000000 +0100 @@ -9216,7 +9216,8 @@ get_pointer_modulus_and_residue (tree ex *residue = 0; code = TREE_CODE (expr); - if (code == ADDR_EXPR) + if (code == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (expr, 0)) != FUNCTION_DECL) { unsigned int bitalign; bitalign = get_object_alignment_1 (TREE_OPERAND (expr, 0), residue); Index: gcc/testsuite/gcc.dg/torture/pr49169.c =================================================================== --- /dev/null 2011-06-20 08:31:41.268810499 +0100 +++ gcc/testsuite/gcc.dg/torture/pr49169.c 2011-06-23 17:52:24.000000000 +0100 @@ -0,0 +1,13 @@ +#include <stdlib.h> +#include <stdint.h> + +int +main (void) +{ + void *p = main; + if ((intptr_t) p & 1) + abort (); + return 0; +} + +/* { dg-final { scan-assembler "abort" } } */