> On Tue, Dec 20, 2011 at 04:04:16PM -0800, Brendan Conoboy wrote: > > On Tue, Dec 20, 2011 at 2:37 PM, Jakub Jelinek <ja...@redhat.com> wrote: > > > This is ok for 4.6 if it has been sufficiently tested. > > > > Okay! Is there any testing you'd like to see beyond the > > aforementioned success with arm and x86_64 linux? > > That is sufficient.
I have checked this in on Doug's behalf (after checking with him, of course ;) after re-bootstrapping it on an arm host just to be paranoid. 2011-12-22 Doug Kwan <dougk...@google.com> Backport from mainline 2011-03-23 Julian Brown <jul...@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...@arm.com> * expr.c (expand_expr_real_1): Correctly handle strict volatile bitfield loads smaller than mode size. Index: testsuite/gcc.dg/volatile-bitfields-1.c =================================================================== --- testsuite/gcc.dg/volatile-bitfields-1.c (revision 0) +++ testsuite/gcc.dg/volatile-bitfields-1.c (revision 0) @@ -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; +} 2011-12-22 Doug Kwan <dougk...@google.com> Backport from mainline 2011-11-20 Joey Ye <joey...@arm.com> * gcc.dg/volatile-bitfields-1.c: New. Index: expr.c =================================================================== --- expr.c (revision 182634) +++ expr.c (working copy) @@ -9186,14 +9186,22 @@ expand_expr_real_1 (tree exp, rtx target || (mode1 != BLKmode && ! direct_load[(int) mode1] && GET_MODE_CLASS (mode) != MODE_COMPLEX_INT && GET_MODE_CLASS (mode) != MODE_COMPLEX_FLOAT && 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 && (((TYPE_ALIGN (TREE_TYPE (tem)) < GET_MODE_ALIGNMENT (mode) || (bitpos % GET_MODE_ALIGNMENT (mode) != 0) || (MEM_P (op0)