This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Create RECORD_NODE for COMMON blocks contain no EQUIVALENCE objects
- From: Canqun Yang <canqun at nudt dot edu dot cn>
- To: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Thu, 24 Mar 2005 22:25:09 +0800 (HKT)
- Subject: Create RECORD_NODE for COMMON blocks contain no EQUIVALENCE objects
- Reply-to: Canqun Yang <canqun at nudt dot edu dot cn>
Hi, all
If the common block contains no equivalence objects,
then make a RECORD_TYPE node, otherwise UNION_TYPE.
This will let the alias analyzer work well when there
is no address overlapping for common variables in the
current common block.
This patch may improve performance for Fortran
programs which contain COMMON blocks. For example, the
SPEC CFP2000 benchmark 171.swim just spend 20 seconds
to execute in train mode, but 29 seconds without this
patch.
Tested on IA-64.
Canqun Yang
Creative Compiler Research Group.
National University of Defense Technology, China.
*** ChangeLog.save Thu Mar 24 21:53:14 2005
--- ChangeLog Thu Mar 24 21:53:02 2005
***************
*** 1,3 ****
--- 1,13 ----
+ 2005-03-24 Canqun Yang <canqun@nudt.edu.cn>
+
+ * trans-common.c (saw_equiv): New static variable.
+ (create_common): Build RECORD_NODE for common blocks contain no
+ equivalence objects.
+ (add_equivalences): Set saw_equiv when needed.
+ (translate_common): Initialize saw_equiv.
+ (create_common, build_field, build_equiv_decl, build_common_decl):
+ change 'union_node' to 'node_type'.
+
2005-03-22 Francois-Xavier Coudert <coudert@clipper.ens.fr>
* check.c (gfc_check_chdir, gfc_check_chdir_sub, gfc_check_kill,
121a122,124
> /* Whether the current common block contains equivalence object or not. */
> static bool saw_equiv;
>
218c221
< build_field (segment_info *h, tree union_type, record_layout_info rli)
---
> build_field (segment_info *h, tree node_type, record_layout_info rli)
236c239
< DECL_FIELD_CONTEXT (field) = union_type;
---
> DECL_FIELD_CONTEXT (field) = node_type;
273c276
< build_equiv_decl (tree union_type, bool is_init)
---
> build_equiv_decl (tree node_type, bool is_init)
281c284
< decl = gfc_create_var (union_type, "equiv");
---
> decl = gfc_create_var (node_type, "equiv");
287c290
< decl = build_decl (VAR_DECL, get_identifier (name), union_type);
---
> decl = build_decl (VAR_DECL, get_identifier (name), node_type);
310c313
< build_common_decl (gfc_common_head *com, tree union_type, bool is_init)
---
> build_common_decl (gfc_common_head *com, tree node_type, bool is_init)
325c328
< tree size = TYPE_SIZE_UNIT (union_type);
---
> tree size = TYPE_SIZE_UNIT (node_type);
347c350
< decl = build_decl (VAR_DECL, get_identifier (com->name), union_type);
---
> decl = build_decl (VAR_DECL, get_identifier (com->name), node_type);
385c388
< tree union_type;
---
> tree node_type;
391,394c394,405
< /* Declare the variables inside the common block. */
< union_type = make_node (UNION_TYPE);
< rli = start_record_layout (union_type);
< field_link = &TYPE_FIELDS (union_type);
---
> /* Declare the variables inside the common block.
> If the current common block contains any equivalence object, then
> make a UNION_TYPE node, otherwise RECORD_TYPE. This will let the
> alias analyzer work well when there is no address overlapping for
> common variables in the current common block. */
> if (saw_equiv)
> node_type = make_node (UNION_TYPE);
> else
> node_type = make_node (RECORD_TYPE);
>
> rli = start_record_layout (node_type);
> field_link = &TYPE_FIELDS (node_type);
398c409
< build_field (s, union_type, rli);
---
> build_field (s, node_type, rli);
411c422
< decl = build_common_decl (com, union_type, is_init);
---
> decl = build_common_decl (com, node_type, is_init);
413c424
< decl = build_equiv_decl (union_type, is_init);
---
> decl = build_equiv_decl (node_type, is_init);
442c453
< ctor = build1 (CONSTRUCTOR, union_type, nreverse(list));
---
> ctor = build1 (CONSTRUCTOR, node_type, nreverse(list));
720a732,733
> if (more)
> saw_equiv = true;
794a808
> saw_equiv = false;