This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Fix PR53937
- From: Richard Guenther <rguenther at suse dot de>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 13 Jul 2012 11:16:21 +0200 (CEST)
- Subject: [PATCH] Fix PR53937
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.
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;