aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.6
diff options
context:
space:
mode:
authorJing Yu <jingyu@google.com>2011-12-19 17:06:49 -0800
committerJing Yu <jingyu@google.com>2011-12-19 17:06:49 -0800
commitd7030123e04baab5dbff9c9ee04c0de99bd9a774 (patch)
treea6581ed186e0c3e7e2734adf24ecfa4b97924319 /gcc-4.6
parent40d7cd0fd78fe2004e2a53c4618c148339b02733 (diff)
downloadtoolchain_gcc-d7030123e04baab5dbff9c9ee04c0de99bd9a774.tar.gz
toolchain_gcc-d7030123e04baab5dbff9c9ee04c0de99bd9a774.tar.bz2
toolchain_gcc-d7030123e04baab5dbff9c9ee04c0de99bd9a774.zip
Backport two upstream patches for bitfield volatile bug.
r171347 and r181549 http://gcc.gnu.org/viewcvs?view=revision&revision=181549 http://gcc.gnu.org/ml/gcc-patches/2011-03/msg01477.html Change-Id: I3f0a433e32eb26015be6173a3b52aac0f6fecf7d
Diffstat (limited to 'gcc-4.6')
-rw-r--r--gcc-4.6/gcc/ChangeLog.google-4_613
-rw-r--r--gcc-4.6/gcc/expr.c12
-rw-r--r--gcc-4.6/gcc/testsuite/ChangeLog.google-4_65
-rw-r--r--gcc-4.6/gcc/testsuite/gcc.dg/volatile-bitfields-1.c23
4 files changed, 51 insertions, 2 deletions
diff --git a/gcc-4.6/gcc/ChangeLog.google-4_6 b/gcc-4.6/gcc/ChangeLog.google-4_6
index 732ae610f..309acfb48 100644
--- a/gcc-4.6/gcc/ChangeLog.google-4_6
+++ b/gcc-4.6/gcc/ChangeLog.google-4_6
@@ -1,3 +1,16 @@
+2011-12-05 Jing Yu <jingyu@google.com>
+
+ Backport r171347 and r181549 from trunk.
+ 2011-03-23 Julian Brown <julian@codesourcery.com>
+
+ * expr.c (expand_expr_real_1): Only use BLKmode for volatile
+ accesses which are not naturally aligned.
+
+ 2011-11-20 Joey Ye <joey.ye@arm.com>
+
+ * expr.c (expand_expr_real_1): Correctly handle strict volatile
+ bitfield loads smaller than mode size.
+
2011-08-16 Guozhi Wei <carrot@google.com>
Backport r174965 from trunk.
diff --git a/gcc-4.6/gcc/expr.c b/gcc-4.6/gcc/expr.c
index 31f04e301..5cb5df7a2 100644
--- a/gcc-4.6/gcc/expr.c
+++ b/gcc-4.6/gcc/expr.c
@@ -9192,8 +9192,16 @@ 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. Do this in following two situations:
+ 1. the access is not already naturally
+ aligned, otherwise "normal" (non-bitfield) volatile fields
+ become non-addressable.
+ 2. the bitsize is narrower than the access size. Need
+ to extract bitfields from the access. */
+ || (volatilep && flag_strict_volatile_bitfields > 0
+ && (bitpos % GET_MODE_ALIGNMENT (mode) != 0
+ || (mode1 != BLKmode
+ && bitsize < GET_MODE_SIZE (mode1) * BITS_PER_UNIT)))
/* If the field isn't aligned enough to fetch as a memref,
fetch it as a bit field. */
|| (mode1 != BLKmode
diff --git a/gcc-4.6/gcc/testsuite/ChangeLog.google-4_6 b/gcc-4.6/gcc/testsuite/ChangeLog.google-4_6
index d0899f72f..15808132a 100644
--- a/gcc-4.6/gcc/testsuite/ChangeLog.google-4_6
+++ b/gcc-4.6/gcc/testsuite/ChangeLog.google-4_6
@@ -1,3 +1,8 @@
+2011-12-05 Jing Yu <jingyu@google.com>
+
+ Backport r171347 and r181549 from trunk.
+ 2011-11-20 Joey Ye <joey.ye@arm.com>
+
2011-08-17 Guozhi Wei <carrot@google.com>
Backport r177357 from trunk.
diff --git a/gcc-4.6/gcc/testsuite/gcc.dg/volatile-bitfields-1.c b/gcc-4.6/gcc/testsuite/gcc.dg/volatile-bitfields-1.c
new file mode 100644
index 000000000..6adda27fe
--- /dev/null
+++ b/gcc-4.6/gcc/testsuite/gcc.dg/volatile-bitfields-1.c
@@ -0,0 +1,23 @@
+/* { dg-options "-fstrict-volatile-bitfields" } */
+/* { dg-do run } */
+
+extern int puts(const char *);
+extern void abort(void) __attribute__((noreturn));
+
+typedef struct {
+ volatile unsigned short a:8, b:8;
+} BitStruct;
+
+BitStruct bits = {1, 2};
+
+void check(int i, int j)
+{
+ if (i != 1 || j != 2) puts("FAIL"), abort();
+}
+
+int main ()
+{
+ check(bits.a, bits.b);
+
+ return 0;
+}