diff options
author | Koen Kooi <koen@dominion.thruhere.net> | 2012-03-23 08:22:26 +0100 |
---|---|---|
committer | Koen Kooi <koen@dominion.thruhere.net> | 2012-03-24 07:35:22 +0100 |
commit | ff0f815593c33f1a82ba4d1cbe41e6b987da1f47 (patch) | |
tree | 22b43fa2e84f25cc948df79f9e9de07e8ec57418 /toolchain-layer/recipes-devtools/gcc/gcc-4.5/gcc-arm-volatile-bitfield-fix.patch | |
parent | 6b22bd198a87b5f113971d8fcd0e7211cd143c7d (diff) | |
download | meta-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.patch | 103 |
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 @@ | |||
1 | Date: Mon, 22 Nov 2010 13:28:54 +0000 | ||
2 | From: Julian Brown <julian at codesourcery dot com> | ||
3 | To: gcc-patches at gcc dot gnu dot org | ||
4 | Cc: DJ Delorie <dj at redhat dot com> | ||
5 | Subject: [PATCH] Volatile bitfields vs. inline asm memory constraints | ||
6 | Message-ID: <20101122132854.0aca431a@rex.config> | ||
7 | Mime-Version: 1.0 | ||
8 | Content-Type: multipart/mixed; boundary="MP_/ONpW806RnQ1ziaYj7_Y5E27" | ||
9 | X-IsSubscribed: yes | ||
10 | Mailing-List: contact gcc-patches-help at gcc dot gnu dot org; run by ezmlm | ||
11 | Precedence: bulk | ||
12 | List-Id: <gcc-patches.gcc.gnu.org> | ||
13 | List-Archive: <http://gcc.gnu.org/ml/gcc-patches/> | ||
14 | List-Post: <mailto:gcc-patches at gcc dot gnu dot org> | ||
15 | List-Help: <mailto:gcc-patches-help at gcc dot gnu dot org> | ||
16 | Sender: gcc-patches-owner at gcc dot gnu dot org | ||
17 | Delivered-To: mailing list gcc-patches at gcc dot gnu dot org | ||
18 | |||
19 | |||
20 | |||
21 | Hi, | ||
22 | |||
23 | This patch fixes the issue in the (Launchpad, not GCC) bug tracker: | ||
24 | |||
25 | https://bugs.launchpad.net/gcc-linaro/+bug/675347 | ||
26 | |||
27 | The problem was introduced by the patch from DJ to honour volatile | ||
28 | bitfield types: | ||
29 | |||
30 | http://gcc.gnu.org/ml/gcc-patches/2010-06/msg01167.html | ||
31 | |||
32 | but not exposed (on ARM) until the option was made the default (on the | ||
33 | Linaro branch) -- it's not yet the default on mainline. | ||
34 | |||
35 | The issue is as follows: after DJ's patch and with | ||
36 | -fstrict-volatile-bitfields, in expr.c:expand_expr_real_1, the if | ||
37 | condition with the comment "In cases where an aligned union has an | ||
38 | unaligned object as a field, we might be extracting a BLKmode value | ||
39 | from an integer-mode (e.g., SImode) object [...]" triggers for a normal | ||
40 | (non-bitfield) volatile field of a struct/class. | ||
41 | |||
42 | But, this appears to be over-eager: in the particular case mentioned | ||
43 | above, when expanding a "volatile int" struct field used as a memory | ||
44 | constraint for an inline asm, we end up with something which is no | ||
45 | longer addressable (I think because of the actions of | ||
46 | extract_bit_field). So, compilation aborts. | ||
47 | |||
48 | My proposed fix is to restrict the conditional by only making it execute | ||
49 | for -fstrict-volatile-bitfields only for non-naturally-aligned accesses: | ||
50 | this appears to work (fixes test in question, and no regressions for | ||
51 | cross to ARM Linux, gcc/g++/libstdc++, with -fstrict-volatile-bitfields | ||
52 | turned on), but I don't know if there will be unintended consequences. | ||
53 | DJ, does it look sane to you? | ||
54 | |||
55 | Incidentally the constraints in the inline asm in the Launchpad | ||
56 | testcase might be slightly dubious (attempting to force (mem (reg)) by | ||
57 | using both "+m" (var) and "r" (&var) constraints), but replacing | ||
58 | them 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 | |||
71 | still leads to a warning (not an error) with trunk and | ||
72 | -fstrict-volatile-bitfields: | ||
73 | |||
74 | atomic-changed.cc:24:35: warning: use of memory input without lvalue in | ||
75 | asm operand 2 is deprecated [enabled by default] | ||
76 | |||
77 | The warning goes away with the attached patch. So, I don't think the | ||
78 | problem is purely that the original inline asm is invalid. | ||
79 | |||
80 | OK to apply, or any comments? | ||
81 | |||
82 | Julian | ||
83 | |||
84 | ChangeLog | ||
85 | |||
86 | gcc/ | ||
87 | * expr.c (expand_expr_real_1): Only use BLKmode for volatile | ||
88 | accesses which are not naturally aligned. | ||
89 | |||
90 | Index: 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 | ||