summaryrefslogtreecommitdiffstats
path: root/toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch
diff options
context:
space:
mode:
authorKoen Kooi <koen@dominion.thruhere.net>2012-03-23 08:22:26 +0100
committerKoen Kooi <koen@dominion.thruhere.net>2012-03-24 07:35:22 +0100
commitff0f815593c33f1a82ba4d1cbe41e6b987da1f47 (patch)
tree22b43fa2e84f25cc948df79f9e9de07e8ec57418 /toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch
parent6b22bd198a87b5f113971d8fcd0e7211cd143c7d (diff)
downloadmeta-openembedded-ff0f815593c33f1a82ba4d1cbe41e6b987da1f47.tar.gz
toolchain-layer: move binutils and gcc from meta-oe into here
Acked-by: Martin Jansa <Martin.Jansa@gmail.com> Acked-by: Eric BĂ©nard <eric@eukrea.com> Acked-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: Koen Kooi <koen@dominion.thruhere.net>
Diffstat (limited to 'toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch')
-rw-r--r--toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch103
1 files changed, 103 insertions, 0 deletions
diff --git a/toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch
new file mode 100644
index 000000000..d5a31d19d
--- /dev/null
+++ b/toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch
@@ -0,0 +1,103 @@
1Date: Mon, 22 Nov 2010 13:28:54 +0000
2From: Julian Brown <julian at codesourcery dot com>
3To: gcc-patches at gcc dot gnu dot org
4Cc: DJ Delorie <dj at redhat dot com>
5Subject: [PATCH] Volatile bitfields vs. inline asm memory constraints
6Message-ID: <20101122132854.0aca431a@rex.config>
7Mime-Version: 1.0
8Content-Type: multipart/mixed; boundary="MP_/ONpW806RnQ1ziaYj7_Y5E27"
9X-IsSubscribed: yes
10Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm
11Precedence: bulk
12List-Id: <gcc-patches.gcc.gnu.org>
13List-Archive: <http://gcc.gnu.org/ml/gcc-patches/>
14List-Post: <mailto:gcc-patches at gcc dot gnu dot org>
15List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org>
16Sender: gcc-patches-owner at gcc dot gnu dot org
17Delivered-To: mailing list gcc-patches at gcc dot gnu dot org
18
19
20
21Hi,
22
23This patch fixes the issue in the (Launchpad, not GCC) bug tracker:
24
25https://bugs.launchpad.net/gcc-linaro/+bug/675347
26
27The problem was introduced by the patch from DJ to honour volatile
28bitfield types:
29
30http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01167.html
31
32but not exposed (on ARM) until the option was made the default (on the
33Linaro branch) -- it's not yet the default on mainline.
34
35The issue is as follows: after DJ's patch and with
36-fstrict-volatile-bitfields, in expr.c:expand_expr_real_1, the if
37condition with the comment "In cases where an aligned union has an
38unaligned object as a field, we might be extracting a BLKmode value
39from an integer-mode (e.g., SImode) object [...]" triggers for a normal
40(non-bitfield) volatile field of a struct/class.
41
42But, this appears to be over-eager: in the particular case mentioned
43above, when expanding a "volatile int" struct field used as a memory
44constraint for an inline asm, we end up with something which is no
45longer addressable (I think because of the actions of
46extract_bit_field). So, compilation aborts.
47
48My proposed fix is to restrict the conditional by only making it execute
49for -fstrict-volatile-bitfields only for non-naturally-aligned accesses:
50this appears to work (fixes test in question, and no regressions for
51cross to ARM Linux, gcc/g++/libstdc++, with -fstrict-volatile-bitfields
52turned on), but I don't know if there will be unintended consequences.
53DJ, does it look sane to you?
54
55Incidentally the constraints in the inline asm in the Launchpad
56testcase might be slightly dubious (attempting to force (mem (reg)) by
57using both "+m" (var) and "r" (&var) constraints), but replacing
58them with e.g.:
59
60 asm volatile("0:\n"
61 "ldrex %[newValue], %[_q_value]\n"
62 "sub %[newValue], %[newValue], #1\n"
63 "strex %[result], %[newValue], %[_q_value]\n"
64 "teq %[result], #0\n"
65 "bne 0b\n"
66 : [newValue] "=&r" (newValue),
67 [result] "=&r" (result)
68 : [_q_value] "Q" (_q_value)
69 : "cc", "memory");
70
71still leads to a warning (not an error) with trunk and
72-fstrict-volatile-bitfields:
73
74atomic-changed.cc:24:35: warning: use of memory input without lvalue in
75asm operand 2 is deprecated [enabled by default]
76
77The warning goes away with the attached patch. So, I don't think the
78problem is purely that the original inline asm is invalid.
79
80OK to apply, or any comments?
81
82Julian
83
84ChangeLog
85
86 gcc/
87 * expr.c (expand_expr_real_1): Only use BLKmode for volatile
88 accesses which are not naturally aligned.
89
90Index: gcc-4_5-branch/gcc/expr.c
91===================================================================
92--- gcc-4_5-branch.orig/gcc/expr.c 2010-12-23 00:42:11.690101002 -0800
93+++ gcc-4_5-branch/gcc/expr.c 2010-12-24 15:07:39.400101000 -0800
94@@ -9029,7 +9029,8 @@
95 && modifier != EXPAND_INITIALIZER)
96 /* If the field is volatile, we always want an aligned
97 access. */
98- || (volatilep && flag_strict_volatile_bitfields > 0)
99+ || (volatilep && flag_strict_volatile_bitfields > 0
100+ && (bitpos % GET_MODE_ALIGNMENT (mode) != 0))
101 /* If the field isn't aligned enough to fetch as a memref,
102 fetch it as a bit field. */
103 || (mode1 != BLKmode