[patch] split FRAME variables back into pieces
Eric Botcazou
ebotcazou@adacore.com
Wed Sep 19 11:00:00 GMT 2012
Hi,
this transformation has been in our tree for a couple of years and was
originally developed for SPARKSkein (http://www.skein-hash.info/node/48),
which is the implementation in SPARK (subset of Ada) of the Skein algorithm.
When nested functions access local variables of their parent, the compiler
creates a special FRAME local variable in the parent, which represents the
non-local frame, and puts into it all the variables accessed non-locally.
If these nested functions are later inlined into their parent, these FRAME
variables generally remain unmodified and this has various drawbacks:
1) the frame of the parent is unnecessarily large,
2) scalarization of aggregates put into the FRAME variables is hindered,
3) debug info for scalars put into the FRAME variables is poor since VTA only
works on GIMPLE registers.
The attached patch makes it so that the compiler splits FRAME variables back
into pieces when all the nested functions have been inlined. The natural
place to implement the transformation would probably be the SRA pass, but this
would require a special path to work around all the heuristics and the pass is
already complicated enough (sorry Martin ;-) The transformation is therefore
implemented as a sub-pass of execute_update_addresses_taken for technical
reasons exposed in the patch.
Tested on x86-64/Linux, OK for the mainline?
2012-09-19 Eric Botcazou <ebotcazou@adacore.com>
* tree.h (DECL_NONLOCAL_FRAME): New macro.
* gimple.c (gimple_ior_addresses_taken_1): Handle non-local frame
structures specially.
* tree-nested.c (get_frame_type): Set DECL_NONLOCAL_FRAME.
* tree-ssa.c (lookup_decl_for_field): New static function.
(split_nonlocal_frames_op): Likewise.
(execute_update_addresses_taken): Break up non-local frame structures
into variables when possible.
* tree-streamer-in.c (unpack_ts_decl_common_value_fields): Stream in
DECL_NONLOCAL_FRAME flag.
* tree-streamer-out.c (pack_ts_decl_common_value_fields): Stream out
DECL_NONLOCAL_FRAME flag.
2012-09-19 Eric Botcazou <ebotcazou@adacore.com>
* gcc.dg/nested-func-9.c: New test.
--
Eric Botcazou
-------------- next part --------------
A non-text attachment was scrubbed...
Name: p.diff
Type: text/x-patch
Size: 9908 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120919/22958d7f/attachment.bin>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: nested-func-9.c
Type: text/x-csrc
Size: 523 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20120919/22958d7f/attachment-0001.bin>
More information about the Gcc-patches
mailing list