Skip to content
This repository has been archived by the owner on Jun 20, 2019. It is now read-only.

Commit

Permalink
Use target_expr based stabilize in indirect_ref
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed May 2, 2018
1 parent b81d3f8 commit 95379b0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
20 changes: 18 additions & 2 deletions gcc/d/d-codegen.cc
Original file line number Diff line number Diff line change
Expand Up @@ -561,6 +561,21 @@ build_unary_op (tree_code code, tree type, tree arg)
care about, storing the value in VALUEP. Callers must ensure that the
returned expression is evaluated before VALUEP. */

tree
stabilize_expr2 (tree *valuep)
{
tree expr = *valuep;

/* No side effects or expression has no value. */
if (!TREE_SIDE_EFFECTS (expr) || VOID_TYPE_P (TREE_TYPE (expr)))
return NULL_TREE;

tree init = force_target_expr (expr);
*valuep = TARGET_EXPR_SLOT (init);

return init;
}

tree
stabilize_expr (tree *valuep)
{
Expand Down Expand Up @@ -1193,6 +1208,7 @@ find_aggregate_field (tree type, tree ident, tree offset)

return NULL_TREE;
}

/* Return a constructor that matches the layout of the class expression EXP. */

tree
Expand Down Expand Up @@ -1530,7 +1546,7 @@ indirect_ref (tree type, tree exp)
return exp;

/* Maybe rewrite: *(e1, e2) => (e1, *e2) */
tree init = stabilize_expr (&exp);
tree init = stabilize_expr2 (&exp);

if (TREE_CODE (TREE_TYPE (exp)) == REFERENCE_TYPE)
exp = fold_build1 (INDIRECT_REF, type, exp);
Expand All @@ -1552,7 +1568,7 @@ build_deref (tree exp)
return exp;

/* Maybe rewrite: *(e1, e2) => (e1, *e2) */
tree init = stabilize_expr (&exp);
tree init = stabilize_expr2 (&exp);

gcc_assert (POINTER_TYPE_P (TREE_TYPE (exp)));

Expand Down
1 change: 1 addition & 0 deletions gcc/d/d-tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ extern void extract_from_method_call (tree, tree &, tree &);
extern tree build_vindex_ref (tree, tree, size_t);
extern tree d_save_expr (tree);
extern tree stabilize_expr (tree *);
extern tree stabilize_expr2 (tree *);
extern tree build_target_expr (tree, tree);
extern tree force_target_expr (tree);
extern tree build_address (tree);
Expand Down

0 comments on commit 95379b0

Please sign in to comment.