Skip to content

Commit

Permalink
compiler: load LHS subexpressions of op= assignment only once
Browse files Browse the repository at this point in the history
  • Loading branch information
ianlancetaylor committed May 17, 2022
1 parent 2b0c837 commit 1bfb823
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gcc/go/gofrontend/MERGE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
f5bc28a30b7503015bbef38afb5812313184e822
9d07072e58ca4f9f05343dfd3475b9f49dae5ec5

The first line of this file holds the git revision number of the last
merge done from the gofrontend repository.
10 changes: 10 additions & 0 deletions gcc/go/gofrontend/statements.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,16 @@ Assignment_operation_statement::do_lower(Gogo*, Named_object*,
Move_ordered_evals moe(b);
this->lhs_->traverse_subexpressions(&moe);

// We can still be left with subexpressions that have to be loaded
// even if they don't have side effects themselves, in case the RHS
// changes variables named on the LHS.
int i;
if (this->lhs_->must_eval_subexpressions_in_order(&i))
{
Move_subexpressions ms(i, b);
this->lhs_->traverse_subexpressions(&ms);
}

Expression* lval = this->lhs_->copy();

Operator op;
Expand Down

0 comments on commit 1bfb823

Please sign in to comment.