Patchwork Fix PR53937

login
register
mail settings
Submitter Richard Guenther
Date July 13, 2012, 9:16 a.m.
Message ID <alpine.LNX.2.00.1207131114410.17088@jbgna.fhfr.qr>
Download mbox | patch
Permalink /patch/170833/
State New
Headers show

Comments

Richard Guenther - July 13, 2012, 9:16 a.m.
We fail to handle constant addresses in get_pointer_alignment_1
so we use too pessimistic alignment when accessing a packed
structure via such a pointer.

Bootstrapped on x86_64-unknown-linux-gnu, testing in progress.

Richard.

2012-07-13  Richard Guenther  <rguenther@suse.de>

	PR middle-end/53937
	* builtins.c (get_pointer_alignment_1): Handle constant
	pointers.

Patch

Index: gcc/builtins.c
===================================================================
--- gcc/builtins.c	(revision 189451)
+++ gcc/builtins.c	(working copy)
@@ -536,6 +536,13 @@  get_pointer_alignment_1 (tree exp, unsig
 	  return false;
 	}
     }
+  else if (TREE_CODE (exp) == INTEGER_CST)
+    {
+      *alignp = BIGGEST_ALIGNMENT;
+      *bitposp = ((TREE_INT_CST_LOW (exp) * BITS_PER_UNIT)
+		  & (BIGGEST_ALIGNMENT - 1));
+      return true;
+    }
 
   *bitposp = 0;
   *alignp = BITS_PER_UNIT;