public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r13-577] compiler: load LHS subexpressions of op= assignment only once
@ 2022-05-17 22:48 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2022-05-17 22:48 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:1bfb823e2a7346ef55bd53a5354770599f7a550b
commit r13-577-g1bfb823e2a7346ef55bd53a5354770599f7a550b
Author: Ian Lance Taylor <iant@golang.org>
Date: Tue May 10 17:05:08 2022 -0700
compiler: load LHS subexpressions of op= assignment only once
Fixes golang/go#52811
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405617
Diff:
---
gcc/go/gofrontend/MERGE | 2 +-
gcc/go/gofrontend/statements.cc | 10 ++++++++++
2 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE
index daa725f9de9..5fa8becde3e 100644
--- a/gcc/go/gofrontend/MERGE
+++ b/gcc/go/gofrontend/MERGE
@@ -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.
diff --git a/gcc/go/gofrontend/statements.cc b/gcc/go/gofrontend/statements.cc
index 95fa3c48709..b3db843365e 100644
--- a/gcc/go/gofrontend/statements.cc
+++ b/gcc/go/gofrontend/statements.cc
@@ -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;
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-05-17 22:48 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-05-17 22:48 [gcc r13-577] compiler: load LHS subexpressions of op= assignment only once Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).