diff mbox

[google] Backport r171347 from trunk to google/gcc-4_6 (issue5396043)

Message ID 20111116085109.E1D5E20CE9@atree.mtv.corp.google.com
State New
Headers show

Commit Message

Doug Kwan (關振德) Nov. 16, 2011, 8:51 a.m. UTC
This patch backports the upstream fix in r171347 for a problem caused by
change in volatile bitfield access.  This is tested by building the
x86 toolchain with tests and checking that volatile bitfield access worked
on ARM.  This is a backport for 4.6 only. 

2011-11-16   Doug Kwan  <dougkwan@google.com>

        Backport r171347 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.


--
This patch is available for review at http://codereview.appspot.com/5396043

Comments

Diego Novillo Nov. 16, 2011, 3:07 p.m. UTC | #1
On Wed, Nov 16, 2011 at 03:51, Doug Kwan <dougkwan@google.com> wrote:
> This patch backports the upstream fix in r171347 for a problem caused by
> change in volatile bitfield access.  This is tested by building the
> x86 toolchain with tests and checking that volatile bitfield access worked
> on ARM.  This is a backport for 4.6 only.
>
> 2011-11-16   Doug Kwan  <dougkwan@google.com>
>
>        Backport r171347 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.

OK.  Were there any testsuite changes for this patch?


Diego.
Richard Earnshaw Nov. 16, 2011, 4:41 p.m. UTC | #2
On 16/11/11 08:51, Doug Kwan wrote:
> This patch backports the upstream fix in r171347 for a problem caused by
> change in volatile bitfield access.  This is tested by building the
> x86 toolchain with tests and checking that volatile bitfield access worked
> on ARM.  This is a backport for 4.6 only. 
> 
> 2011-11-16   Doug Kwan  <dougkwan@google.com>
> 
>         Backport r171347 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.
> 
So Joey Ye posted the following patch, which I think is needed to fix a
regression that that patch introduces.

http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01390.html

However, it's not been reviewed yet :-(

R.
Doug Kwan (關振德) Nov. 16, 2011, 9:11 p.m. UTC | #3
Thanks Richard.  I will wait for that patch.

-Doug

On Wed, Nov 16, 2011 at 8:41 AM, Richard Earnshaw <rearnsha@arm.com> wrote:
> On 16/11/11 08:51, Doug Kwan wrote:
>> This patch backports the upstream fix in r171347 for a problem caused by
>> change in volatile bitfield access.  This is tested by building the
>> x86 toolchain with tests and checking that volatile bitfield access worked
>> on ARM.  This is a backport for 4.6 only.
>>
>> 2011-11-16   Doug Kwan  <dougkwan@google.com>
>>
>>         Backport r171347 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.
>>
> So Joey Ye posted the following patch, which I think is needed to fix a
> regression that that patch introduces.
>
> http://gcc.gnu.org/ml/gcc-patches/2011-11/msg01390.html
>
> However, it's not been reviewed yet :-(
>
> R.
>
>
diff mbox

Patch

Index: gcc/expr.c
===================================================================
--- gcc/expr.c	(revision 181400)
+++ gcc/expr.c	(working copy)
@@ -9200,8 +9200,11 @@ 
 		&& 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