2007-02-15 Alexandre Oliva <aoliva@redhat.com>
+ * tree-sra.c (instantiate_missing_elements): Canonicalize
+ bit-field types.
+ (sra_build_assignment): New.
+ (generate_copy_inout, generate_element_copy,
+ generate_element_zero, generate_one_element_init): Use it.
+
+2007-02-15 Alexandre Oliva <aoliva@redhat.com>
+
+ * tree-sra.c (instantiate_missing_elements): Canonicalize
+ bit-field types.
+ (sra_build_assignment): New.
+ (generate_copy_inout, generate_element_copy,
+ generate_element_zero, generate_one_element_init): Use it.
+
+2007-02-15 Alexandre Oliva <aoliva@redhat.com>
+
* dwarf2out.c (dwarf2out_finish): Accept namespaces as context of
limbo die nodes.
/* Scalar Replacement of Aggregates (SRA) converts some structure
references into scalar references, exposing them to the scalar
optimizers.
- Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
+ Copyright (C) 2003, 2004, 2005, 2006, 2007
+ Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
tree f;
for (f = TYPE_FIELDS (type); f ; f = TREE_CHAIN (f))
if (TREE_CODE (f) == FIELD_DECL)
- instantiate_missing_elements_1 (elt, f, TREE_TYPE (f));
+ {
+ tree field_type = TREE_TYPE (f);
+
+ /* canonicalize_component_ref() unwidens some bit-field
+ types (not marked as DECL_BIT_FIELD in C++), so we
+ must do the same, lest we may introduce type
+ mismatches. */
+ if (INTEGRAL_TYPE_P (field_type)
+ && DECL_MODE (f) != TYPE_MODE (field_type))
+ field_type = TREE_TYPE (get_unwidened (build3 (COMPONENT_REF,
+ field_type,
+ elt->element,
+ f, NULL_TREE),
+ NULL_TREE));
+
+ instantiate_missing_elements_1 (elt, f, field_type);
+ }
break;
}
return elt->element;
}
+static tree
+sra_build_assignment (tree dst, tree src)
+{
+ gcc_assert (TYPE_CANONICAL (TYPE_MAIN_VARIANT (TREE_TYPE (dst)))
+ == TYPE_CANONICAL (TYPE_MAIN_VARIANT (TREE_TYPE (src))));
+ return build2 (GIMPLE_MODIFY_STMT, void_type_node, dst, src);
+}
+
/* Generate a set of assignment statements in *LIST_P to copy all
instantiated elements under ELT to or from the equivalent structure
rooted at EXPR. COPY_OUT controls the direction of the copy, with
i = c->replacement;
t = build2 (COMPLEX_EXPR, elt->type, r, i);
- t = build2 (GIMPLE_MODIFY_STMT, void_type_node, expr, t);
+ t = sra_build_assignment (expr, t);
SSA_NAME_DEF_STMT (expr) = t;
append_to_statement_list (t, list_p);
}
else if (elt->replacement)
{
if (copy_out)
- t = build2 (GIMPLE_MODIFY_STMT, void_type_node, elt->replacement, expr);
+ t = sra_build_assignment (elt->replacement, expr);
else
- t = build2 (GIMPLE_MODIFY_STMT, void_type_node, expr, elt->replacement);
+ t = sra_build_assignment (expr, elt->replacement);
append_to_statement_list (t, list_p);
}
else
gcc_assert (src->replacement);
- t = build2 (GIMPLE_MODIFY_STMT, void_type_node, dst->replacement,
- src->replacement);
+ t = sra_build_assignment (dst->replacement, src->replacement);
append_to_statement_list (t, list_p);
}
}
gcc_assert (elt->is_scalar);
t = fold_convert (elt->type, integer_zero_node);
- t = build2 (GIMPLE_MODIFY_STMT, void_type_node, elt->replacement, t);
+ t = sra_build_assignment (elt->replacement, t);
append_to_statement_list (t, list_p);
}
}
generate_one_element_init (tree var, tree init, tree *list_p)
{
/* The replacement can be almost arbitrarily complex. Gimplify. */
- tree stmt = build2 (GIMPLE_MODIFY_STMT, void_type_node, var, init);
+ tree stmt = sra_build_assignment (var, init);
gimplify_and_add (stmt, list_p);
}