+2005-03-26 Canqun Yang <canqun@nudt.edu.cn>
+
+ * trans-common.c (create_common): Build RECORD_NODE for common blocks
+ contain no equivalence objects.
+ (add_equivalences): New argument saw_equiv.
+ (trans_common): New local variable saw_equiv.
+ (finish_equivalences): Add a local variable dummy, Always pass true
+ for the 3rd parameter to create_common.
+
2005-03-25 Steven G. Kargl <kargls@comcast.net>
* intrinsic.texi: Fix "make dvi"
backend declarations for all of the elements. */
static void
-create_common (gfc_common_head *com, segment_info * head)
+create_common (gfc_common_head *com, segment_info * head, bool saw_equiv)
{
segment_info *s, *next_s;
tree union_type;
tree decl;
bool is_init = false;
- /* Declare the variables inside the common block. */
- union_type = make_node (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)
+ union_type = make_node (UNION_TYPE);
+ else
+ union_type = make_node (RECORD_TYPE);
+
rli = start_record_layout (union_type);
field_link = &TYPE_FIELDS (union_type);
segment list multiple times to include indirect equivalences. */
static void
-add_equivalences (void)
+add_equivalences (bool *saw_equiv)
{
segment_info *f;
bool more;
{
f->sym->equiv_built = 1;
more = find_equivalence (f);
+ if (more)
+ *saw_equiv = true;
}
}
}
HOST_WIDE_INT current_offset;
unsigned HOST_WIDE_INT align;
unsigned HOST_WIDE_INT max_align;
+ bool saw_equiv;
common_segment = NULL;
current_offset = 0;
max_align = 1;
+ saw_equiv = false;
/* Add symbols to the segment. */
for (sym = var_list; sym; sym = sym->common_next)
/* Add all objects directly or indirectly equivalenced with this
symbol. */
- add_equivalences ();
+ add_equivalences (&saw_equiv);
if (current_segment->offset < 0)
gfc_error ("The equivalence set for '%s' cause an invalid "
common->name, &common->where, common_segment->offset);
}
- create_common (common, common_segment);
+ create_common (common, common_segment, saw_equiv);
}
gfc_symbol *sym;
HOST_WIDE_INT offset;
unsigned HOST_WIDE_INT align;
+ bool dummy;
for (z = ns->equiv; z; z = z->next)
for (y = z->eq; y; y = y->eq)
current_segment = get_segment_info (sym, 0);
/* All objects directly or indirectly equivalenced with this symbol. */
- add_equivalences ();
+ add_equivalences (&dummy);
/* Align the block. */
offset = align_segment (&align);
apply_segment_offset (current_segment, offset);
/* Create the decl. */
- create_common (NULL, current_segment);
+ create_common (NULL, current_segment, true);
break;
}
}