[PR87054] fix unaligned access
commitf2160a0e00085555889ad684408a4fbc3d06e63b
authoraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Sep 2018 19:34:44 +0000 (20 19:34 +0000)
committeraoliva <aoliva@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 20 Sep 2018 19:34:44 +0000 (20 19:34 +0000)
tree420d98d2ccab135a9a94d7371b6f9f0f1ae6acd6
parentb2bf47a641afe45b7788f8c7886596f5fbe13b3c
[PR87054] fix unaligned access

Building an ADDR_EXPR uses the canonical type to build the pointer
type, but then, as we dereference it, we lose track of lax alignment
known to apply to the dereferenced object.  This might not be a
problem in general, but it is when the compiler implicitly introduces
address taking and dereferencing, as it does for asm statements, and
as it may do in some loop optimizations.

From: Richard Biener <rguenther@suse.de>
for  gcc/ChangeLog

PR middle-end/87054
* gimplify.c (gimplify_expr): Retain alignment of
addressable lvalue in dereference.

From: Alexandre Oliva <oliva@adacore.com>
for  gcc/testsuite/ChangeLog

PR middle-end/87054
* gcc.dg/pr87054.c: New.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@264450 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/gimplify.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/pr87054.c [new file with mode: 0644]