summaryrefslogtreecommitdiffstats
path: root/patches/gcc-4.6.2/0001-Volatile-bitfields-vs.-inline-asm-memory-constraints.patch
blob: b2623260189968af9d95a8f46b1b04276567b95b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
From: Michael Olbrich <m.olbrich@pengutronix.de>
Date: Wed, 23 Nov 2011 15:43:22 +0100
Subject: [PATCH] Volatile bitfields vs. inline asm memory constraints

taken from trunk.
http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01477.html

gcc/
* expr.c (expand_expr_real_1): Only use BLKmode for volatile
accesses which are not naturally aligned.

Patch taken from Debian

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
---
 gcc/expr.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/gcc/expr.c b/gcc/expr.c
index c4a00aa..03f51f4 100644
--- a/gcc/expr.c
+++ b/gcc/expr.c
@@ -9189,8 +9189,11 @@ expand_expr_real_1 (tree exp, rtx target, enum machine_mode tmode,
 		&& modifier != EXPAND_CONST_ADDRESS
 		&& modifier != EXPAND_INITIALIZER)
 	    /* If the field is volatile, we always want an aligned
-	       access.  */
-	    || (volatilep && flag_strict_volatile_bitfields > 0)
+	       access.  Only do this if the access is not already naturally
+	       aligned, otherwise "normal" (non-bitfield) volatile fields
+	       become non-addressable.  */
+	    || (volatilep && flag_strict_volatile_bitfields > 0
+		&& (bitpos % GET_MODE_ALIGNMENT (mode) != 0))
 	    /* If the field isn't aligned enough to fetch as a memref,
 	       fetch it as a bit field.  */
 	    || (mode1 != BLKmode