This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH][C++] Fix PR43075, really remove all zero-sized stores
On 02/16/2010 11:19 AM, Jason Merrill wrote:
I'm going to try moving the integer_zerop (cp_expr_size) code to the
INIT_EXPR/MODIFY_EXPR section of cp_gimplify_expr.
This seems to do the trick. Does it make sense to you?
Jason
commit 1dde0bfe5ce842b72c7b16cc2df3bc421dbd93ce
Author: Jason Merrill <jason@redhat.com>
Date: Tue Feb 16 11:35:17 2010 -0500
PR c++/43075
* cp-gimplify.c (cp_gimplify_expr): Handle zero-sized stores here.
(cp_genericize_r): Not here.
diff --git a/gcc/cp/cp-gimplify.c b/gcc/cp/cp-gimplify.c
index cf81350..7a395b6 100644
--- a/gcc/cp/cp-gimplify.c
+++ b/gcc/cp/cp-gimplify.c
@@ -555,16 +555,24 @@ cp_gimplify_expr (tree *expr_p, gimple_seq *pre_p, gimple_seq *post_p)
/* Fall through. */
case MODIFY_EXPR:
{
- /* If the back end isn't clever enough to know that the lhs and rhs
- types are the same, add an explicit conversion. */
tree op0 = TREE_OPERAND (*expr_p, 0);
tree op1 = TREE_OPERAND (*expr_p, 1);
- if (!error_operand_p (op0)
- && !error_operand_p (op1)
- && (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op0))
- || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op1)))
- && !useless_type_conversion_p (TREE_TYPE (op1), TREE_TYPE (op0)))
+ /* If this type is all padding, don't perform the assignment. */
+ tree size0 = cp_expr_size (op0);
+ tree size1 = cp_expr_size (op1);
+ if ((size0 && integer_zerop (size0))
+ || (size1 && integer_zerop (size1)))
+ *expr_p = build2 (COMPOUND_EXPR, TREE_TYPE (*expr_p), op0, op1);
+
+ /* If the back end isn't clever enough to know that the lhs and rhs
+ types are the same, add an explicit conversion. */
+ else if (!error_operand_p (op0)
+ && !error_operand_p (op1)
+ && (TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op0))
+ || TYPE_STRUCTURAL_EQUALITY_P (TREE_TYPE (op1)))
+ && !useless_type_conversion_p (TREE_TYPE (op1),
+ TREE_TYPE (op0)))
TREE_OPERAND (*expr_p, 1) = build1 (VIEW_CONVERT_EXPR,
TREE_TYPE (op0), op1);
}
@@ -882,15 +890,6 @@ cp_genericize_r (tree *stmt_p, int *walk_subtrees, void *data)
*walk_subtrees = 0;
}
- else if (TREE_CODE (stmt) == MODIFY_EXPR
- && (integer_zerop (cp_expr_size (TREE_OPERAND (stmt, 0)))
- || integer_zerop (cp_expr_size (TREE_OPERAND (stmt, 1)))))
- {
- *stmt_p = build2 (COMPOUND_EXPR, TREE_TYPE (stmt),
- TREE_OPERAND (stmt, 0),
- TREE_OPERAND (stmt, 1));
- }
-
pointer_set_insert (p_set, *stmt_p);
return NULL;