[PATCH] Disable optimization for volatile object

Eric Botcazou ebotcazou@adacore.com
Thu Apr 23 17:21:00 GMT 2009


> C if you like, but Ada is also fine ;)

OK, here's the complete patch + testcase.  This exercises pragma Atomic in 
Ada, whose implementation strategy is to generate extra temporaries and block 
moves in the FE, put pragma Volatile on the atomic objects and hope that the 
middle-end won't retrofit things.  The testcase doesn't pass without the bits 
in the gimplifier.

Tested on i586-suse-linux, applied on the mainline.


2009-04-23  Eric Botcazou  <ebotcazou@adacore.com>

        * gimplify.c (gimplify_modify_expr_rhs) <VAR_DECL>: Do not do a direct
        assignment from the constructor either if the target is volatile.
ada/
	* einfo.ads (Is_True_Constant): Lift restriction on atomic objects.
	* sinfo.ads (Object Declaration): Likewise.
	(Assignment Statement): Likewise.
	* freeze.adb (Expand_Atomic_Aggregate): Remove useless test.
	Do not force Is_True_Constant to false on the temporary.
	(Freeze_Entity): Do not force Is_True_Constant to false on names on
	the RHS of object declarations.
	* gcc-interface/trans.c (lvalue_required_p) <N_Object_Declaration>:
	New case.  Return 1 if the object is atomic.
	<N_Assignment_Statement>: Likewise.


2009-04-23  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/atomic1.adb: New test.
	* gnat.dg/atomic1_pkg.ads: New helper.


-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-diff
Size: 8462 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090423/36269596/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atomic1.adb
Type: text/x-adasrc
Size: 379 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090423/36269596/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: atomic1_pkg.ads
Type: text/x-adasrc
Size: 1024 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090423/36269596/attachment-0002.bin>


More information about the Gcc-patches mailing list