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

Commit 605964d

Browse files
committed
Use target_expr based stabilize in build_struct_comparison
1 parent 48b809b commit 605964d

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

gcc/d/d-codegen.cc

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ stabilize_expr2 (tree *valuep)
587587
|| VOID_TYPE_P (TREE_TYPE (expr)))
588588
return NULL_TREE;
589589

590+
/* Stabilize only the right hand side of compound expressions. */
591+
if (TREE_CODE (expr) == COMPOUND_EXPR)
592+
{
593+
tree lhs = TREE_OPERAND (expr, 0);
594+
tree rhs = TREE_OPERAND (expr, 1);
595+
lhs = compound_expr (lhs, stabilize_expr2 (&rhs));
596+
*valuep = rhs;
597+
return lhs;
598+
}
599+
590600
tree init = force_target_expr (expr);
591601
*valuep = TARGET_EXPR_SLOT (init);
592602

@@ -929,13 +939,10 @@ build_struct_comparison (tree_code code, StructDeclaration *sd,
929939
return build_boolop (code, integer_zero_node, integer_zero_node);
930940

931941
/* Make temporaries to prevent multiple evaluations. */
932-
tree t1init = stabilize_expr (&t1);
933-
tree t2init = stabilize_expr (&t2);
942+
tree t1init = stabilize_expr2 (&t1);
943+
tree t2init = stabilize_expr2 (&t2);
934944
tree result;
935945

936-
t1 = d_save_expr (t1);
937-
t2 = d_save_expr (t2);
938-
939946
/* Bitwise comparison of structs not returned in memory may not work
940947
due to data holes loosing its zero padding upon return.
941948
As a heuristic, small structs are not compared using memcmp either. */
@@ -1337,6 +1344,12 @@ component_ref (tree object, tree field)
13371344
if (error_operand_p (object) || error_operand_p (field))
13381345
return error_mark_node;
13391346

1347+
if (TREE_CODE (object) == COMPOUND_EXPR)
1348+
{
1349+
tree result = component_ref (TREE_OPERAND (object, 1), field);
1350+
return compound_expr (TREE_OPERAND (object, 0), result);
1351+
}
1352+
13401353
gcc_assert (TREE_CODE (field) == FIELD_DECL);
13411354

13421355
/* If the FIELD is from an anonymous aggregate, generate a reference

0 commit comments

Comments
 (0)