[PATCH] Fix tree node sharing problem (2/2)

Eric Botcazou ebotcazou@adacore.com
Wed Nov 29 09:02:00 GMT 2006


Hi,

Ada is very sensitive to tree node sharing because it deals with a lot of 
parameterized global types.  When the variable components are gimplified via 
gimplify_type_sizes, they cause temporaries to be created and these are tied 
to a given subprogram; hence the gimplification cannot occur on the original 
expression attached to the type but on a copy that has previously been 
created when sharing was detected.  This is the mark/copy-if-shared/unmark 
mechanism in the gimplifier.

The current mechanism doesn't work well in two cases: pointers to scalar types 
with variable bounds (previous message) and complex chains of variable-sized 
aggregate types involving SAVE_EXPRs (this message).

In the second case, the problem is that the unsharing phase of gimplification 
stops at SAVE_EXPRs, on the grounds that SAVE_EXPRs must by definition not be 
copied.  But nodes under the SAVE_EXPRs can be shared too (here between the 
elaboration procedure of the spec of a package and that of its body) and thus 
needs to be unshared too.

Therefore the proposed fix is to teach the gimplifier to unshare nodes under
SAVE_EXPRs too, without of course unsharing the SAVE_EXPRs themselves.

Bootstrapped/regtested on i586-suse-linux, OK for mainline?


2006-11-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gimplify.c (mostly_copy_tree_r): Copy trees under SAVE_EXPR
	and TARGET_EXPR nodes.  Stop at BIND_EXPR nodes.
	(copy_if_shared_r): Remove redundant code dealing with types,
	decls and constants.  Remove bogus ATTRIBUTE_UNUSED marker.
	(unmark_visited_r): Remove bogus ATTRIBUTE_UNUSED marker.
ada/
	* trans.c (unshare_save_expr): Delete.
	(gigi): Do not unshare trees under SAVE_EXPRs here.


2006-11-29  Eric Botcazou  <ebotcazou@adacore.com>

	* gnat.dg/varsize_aggregates.adb: New test.


:ADDPATCH gimplifier:

-- 
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f708-005.diff
Type: text/x-diff
Size: 5475 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: f708-005_ada.diff
Type: text/x-diff
Size: 2820 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0001.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.adb
Type: text/x-adasrc
Size: 590 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0002.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.ads
Type: text/x-adasrc
Size: 315 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0003.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: q.ads
Type: text/x-adasrc
Size: 163 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0004.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: r.ads
Type: text/x-adasrc
Size: 191 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0005.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: s.ads
Type: text/x-adasrc
Size: 53 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20061129/f9c0b71e/attachment-0006.bin>


More information about the Gcc-patches mailing list