+2004-07-23 Diego Novillo <dnovillo@redhat.com>
+
+ PR tree-optimization/16688
+ PR tree-optimization/16689
+ * tree-ssa-alias.c (setup_pointers_and_addressables): Remove
+ unnecessary initialization of 'tag'.
+ (get_tmt_for): Check that the new type tag has the same alias
+ set as the pointed-to type.
+ (group_aliases): Only regular variables need to be removed
+ from the alias set of a name tag.
+ * tree-ssa-copy.c (may_propagate_copy): Do not allow copy
+ propagation if the two types are not compatible.
+ (merge_alias_info): Rename from replace_ssa_names_ann.
+ Add more checking.
+ (replace_exp_1): If both arguments are SSA_NAMEs, check that
+ the propagation can be done.
+ Only call merge_alias_info on pointers.
+ (propagate_value): Likewise.
+ * tree-ssa-copyrename.c: Include langhooks.h.
+ (copy_rename_partition_coalesce): Call replace_ssa_name_symbol
+ to do the merging.
+ Do not coalesce variables with incompatible types.
+ (rename_ssa_copies): Call replace_ssa_name_symbol.
+ * tree-ssa.c (verify_ssa_name): Verify that the SSA_NAME has
+ the same type as the underlying _DECL.
+ * tree-ssanames.c (replace_ssa_name_symbol): New function.
+ * tree.h (replace_ssa_name_symbol): Declare.
+
2004-07-23 Richard Henderson <rth@redhat.com>
PR c++/16277
tree mt_orig = var_ann (SSA_NAME_VAR (orig))->type_mem_tag;
if (mt_dest && mt_orig && mt_dest != mt_orig)
return false;
+ else if (!lang_hooks.types_compatible_p (type_d, type_o))
+ return false;
}
/* If the destination is a SSA_NAME for a virtual operand, then we have
return true;
}
-/* Given two SSA_NAMEs, replace the annotations for the one referred to by OP
- with VAR's annotations.
-
- If OP is a pointer, copy the memory tag used originally by OP into
- VAR. This is needed in cases where VAR had never been dereferenced in the
- program.
- If FOR_PROPAGATION is true, then perform additional checks to ensure
- that const/copy propagation of var for OP is valid. */
+/* Given two SSA_NAMEs pointers ORIG and NEW such that we are copy
+ propagating NEW into ORIG, consolidate aliasing information so that
+ they both share the same memory tags. */
static void
-replace_ssa_names_ann (tree op,
- tree var,
- bool for_propagation ATTRIBUTE_UNUSED)
+merge_alias_info (tree orig, tree new)
{
+ tree new_sym = SSA_NAME_VAR (new);
+ tree orig_sym = SSA_NAME_VAR (orig);
+ var_ann_t new_ann = var_ann (new_sym);
+ var_ann_t orig_ann = var_ann (orig_sym);
+
#if defined ENABLE_CHECKING
- if (for_propagation && !may_propagate_copy (op, var))
+ if (!POINTER_TYPE_P (TREE_TYPE (orig))
+ || !POINTER_TYPE_P (TREE_TYPE (new))
+ || !lang_hooks.types_compatible_p (TREE_TYPE (orig), TREE_TYPE (new)))
abort ();
-#endif
- /* If VAR doesn't have a memory tag, copy the one from the original
- operand. Also copy the dereferenced flags. */
- if (POINTER_TYPE_P (TREE_TYPE (op)))
- {
- var_ann_t new_ann = var_ann (SSA_NAME_VAR (var));
- var_ann_t orig_ann = var_ann (SSA_NAME_VAR (op));
-
- if (new_ann->type_mem_tag == NULL_TREE)
- new_ann->type_mem_tag = orig_ann->type_mem_tag;
- else if (orig_ann->type_mem_tag == NULL_TREE)
- orig_ann->type_mem_tag = new_ann->type_mem_tag;
- else if (new_ann->type_mem_tag != orig_ann->type_mem_tag)
- abort ();
- }
+ /* If the pointed-to alias sets are different, these two pointers
+ would never have the same memory tag. In this case, NEW should
+ not have been propagated into ORIG. */
+ if (get_alias_set (TREE_TYPE (TREE_TYPE (new_sym)))
+ != get_alias_set (TREE_TYPE (TREE_TYPE (orig_sym))))
+ abort ();
+#endif
+ /* Merge type-based alias info. */
+ if (new_ann->type_mem_tag == NULL_TREE)
+ new_ann->type_mem_tag = orig_ann->type_mem_tag;
+ else if (orig_ann->type_mem_tag == NULL_TREE)
+ orig_ann->type_mem_tag = new_ann->type_mem_tag;
+ else if (new_ann->type_mem_tag != orig_ann->type_mem_tag)
+ abort ();
}
replacement is done to propagate a value or not. */
static void
-replace_exp_1 (use_operand_p op_p, tree val, bool for_propagation)
+replace_exp_1 (use_operand_p op_p, tree val,
+ bool for_propagation ATTRIBUTE_UNUSED)
{
+ tree op = USE_FROM_PTR (op_p);
+
+#if defined ENABLE_CHECKING
+ if (for_propagation
+ && TREE_CODE (op) == SSA_NAME
+ && TREE_CODE (val) == SSA_NAME
+ && !may_propagate_copy (op, val))
+ abort ();
+#endif
+
if (TREE_CODE (val) == SSA_NAME)
{
- if (TREE_CODE (USE_FROM_PTR (op_p)) == SSA_NAME)
- replace_ssa_names_ann (USE_FROM_PTR (op_p), val, for_propagation);
+ if (TREE_CODE (op) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (op)))
+ merge_alias_info (op, val);
SET_USE (op_p, val);
}
else
void
propagate_tree_value (tree *op_p, tree val)
{
+#if defined ENABLE_CHECKING
+ if (TREE_CODE (val) == SSA_NAME
+ && TREE_CODE (*op_p) == SSA_NAME
+ && !may_propagate_copy (*op_p, val))
+ abort ();
+#endif
+
if (TREE_CODE (val) == SSA_NAME)
{
- if (TREE_CODE (*op_p) == SSA_NAME)
- replace_ssa_names_ann (*op_p, val, true);
+ if (TREE_CODE (*op_p) == SSA_NAME && POINTER_TYPE_P (TREE_TYPE (*op_p)))
+ merge_alias_info (*op_p, val);
*op_p = val;
}
else
#include "tree-dump.h"
#include "tree-ssa-live.h"
#include "tree-pass.h"
+#include "langhooks.h"
extern void rename_ssa_copies (void);
gimp2 = false;
}
+ /* Don't coalesce if the two variables aren't type compatible. */
+ if (!lang_hooks.types_compatible_p (TREE_TYPE (root1), TREE_TYPE (root2)))
+ {
+ if (debug)
+ fprintf (debug, " : Incompatible types. No coalesce.\n");
+ return;
+ }
+
/* Merge the two partitions. */
p3 = partition_union (map->var_partition, p1, p2);
/* Set the root variable of the partition to the better choice, if there is
one. */
if (!gimp2)
- SSA_NAME_VAR (partition_to_var (map, p3)) = root2;
+ replace_ssa_name_symbol (partition_to_var (map, p3), root2);
else
if (!gimp1)
- SSA_NAME_VAR (partition_to_var (map, p3)) = root1;
+ replace_ssa_name_symbol (partition_to_var (map, p3), root1);
/* Update the various flag widgitry of the current base representative. */
ann3 = var_ann (SSA_NAME_VAR (partition_to_var (map, p3)));
fprintf (debug, "\n");
}
}
- SSA_NAME_VAR (var) = SSA_NAME_VAR (part_var);
+ replace_ssa_name_symbol (var, SSA_NAME_VAR (part_var));
}
delete_var_map (map);