public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* PR 49169: testing the alignment of a function
@ 2011-06-24 14:47 Richard Sandiford
  2011-06-24 16:58 ` Richard Guenther
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Sandiford @ 2011-06-24 14:47 UTC (permalink / raw)
  To: gcc-patches

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?

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" } } */

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

end of thread, other threads:[~2011-06-29  9:20 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-24 14:47 PR 49169: testing the alignment of a function Richard Sandiford
2011-06-24 16:58 ` Richard Guenther
2011-06-27 13:46   ` H.J. Lu
2011-06-29  8:40     ` Richard Sandiford
2011-06-29  9:54       ` Richard Guenther

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