This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH to aggregate returns
- From: Jason Merrill <jason at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Thu, 21 Aug 2003 11:18:02 -0400
- Subject: Re: C++ PATCH to aggregate returns
- References: <wvld6ezhf50.fsf@prospero.boston.redhat.com>
Here's the tree-ssa only part of this patch, to remove the duplicate copy
of this code in cp-simplify.c.
Tested athlon-pc-linux-gnu, applied to tree-ssa.
2003-08-21 Jason Merrill <jason@redhat.com>
* cp-simplify.c (cp_gimplify_expr): Use simplify_aggr_init_expr.
(cp_gimplify_init_expr): Don't call it here.
(gimplify_aggr_init_expr): Remove.
*** cp-simplify.c.~1~ Thu Aug 21 01:25:46 2003
--- cp-simplify.c Thu Aug 21 03:47:13 2003
*************** cp_gimplify_expr (tree *expr_p, tree *pr
*** 128,134 ****
return 1;
case AGGR_INIT_EXPR:
! gimplify_aggr_init_expr (expr_p);
return 1;
case THROW_EXPR:
--- 128,134 ----
return 1;
case AGGR_INIT_EXPR:
! simplify_aggr_init_expr (expr_p);
return 1;
case THROW_EXPR:
*************** cp_gimplify_init_expr (tree *expr_p, tre
*** 193,283 ****
gimplify_expr (&to, pre_p, post_p, is_gimple_modify_expr_lhs, fb_lvalue);
TREE_OPERAND (from, 2) = to;
*expr_p = from;
- gimplify_aggr_init_expr (expr_p);
}
}
- /* Replace the AGGR_INIT_EXPR at *TP with an equivalent CALL_EXPR. */
-
- void
- gimplify_aggr_init_expr (tree *tp)
- {
- tree aggr_init_expr = *tp;
-
- /* Form an appropriate CALL_EXPR. */
- tree fn = TREE_OPERAND (aggr_init_expr, 0);
- tree args = TREE_OPERAND (aggr_init_expr, 1);
- tree slot = TREE_OPERAND (aggr_init_expr, 2);
- tree type = TREE_TYPE (aggr_init_expr);
-
- tree call_expr;
- enum style_t { ctor, arg, pcc } style;
-
- if (AGGR_INIT_VIA_CTOR_P (aggr_init_expr))
- style = ctor;
- #ifdef PCC_STATIC_STRUCT_RETURN
- else if (1)
- style = pcc;
- #endif
- else if (TREE_ADDRESSABLE (type))
- style = arg;
- else
- /* We shouldn't build an AGGR_INIT_EXPR if we don't need any special
- handling. See build_cplus_new. */
- abort ();
-
- if (style == ctor || style == arg)
- {
- /* Pass the address of the slot. If this is a constructor, we
- replace the first argument; otherwise, we tack on a new one. */
- if (style == ctor)
- args = TREE_CHAIN (args);
-
- cxx_mark_addressable (slot);
- args = tree_cons (NULL_TREE,
- build1 (ADDR_EXPR,
- build_pointer_type (TREE_TYPE (slot)),
- slot),
- args);
- }
-
- call_expr = build (CALL_EXPR,
- TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))),
- fn, args, NULL_TREE);
- TREE_SIDE_EFFECTS (call_expr) = 1;
-
- if (style == arg)
- {
- /* Tell the backend that we've added our return slot to the argument
- list. */
- CALL_EXPR_HAS_RETURN_SLOT_ADDR (call_expr) = 1;
- /* And don't let anyone use the value of the call directly in a
- larger expression. */
- TREE_TYPE (call_expr) = void_type_node;
- }
- else if (style == pcc)
- {
- /* If we're using the non-reentrant PCC calling convention, then we
- need to copy the returned value out of the static buffer into the
- SLOT. */
- int old_ac = flag_access_control;
-
- flag_access_control = 0;
- call_expr = build_aggr_init (slot, call_expr,
- DIRECT_BIND | LOOKUP_ONLYCONVERTING);
- flag_access_control = old_ac;
- }
-
- /* We want to use the value of the initialized location as the
- result. */
- call_expr = build (COMPOUND_EXPR, type,
- call_expr, slot);
-
- /* Replace the AGGR_INIT_EXPR with the CALL_EXPR. */
- TREE_CHAIN (call_expr) = TREE_CHAIN (aggr_init_expr);
- *tp = call_expr;
- }
-
/* Gimplify a MUST_NOT_THROW_EXPR. */
static void
--- 193,201 ----