diff options
author | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-05-12 22:13:01 +0000 |
---|---|---|
committer | Ian Lance Taylor <ian@gcc.gnu.org> | 2015-05-12 22:13:01 +0000 |
commit | 38109dbe011a7f69dc36c402186f6ffb2b385ac5 (patch) | |
tree | 1068b1cbe6a9bafec00ef2500175bb992cd8cfec | |
parent | 7e269fe8753df7018b2bcf29fe1bff3e01d09138 (diff) | |
download | gcc-38109dbe011a7f69dc36c402186f6ffb2b385ac5.zip gcc-38109dbe011a7f69dc36c402186f6ffb2b385ac5.tar.gz gcc-38109dbe011a7f69dc36c402186f6ffb2b385ac5.tar.bz2 |
compiler: If unary & does not escape, the var does not escape.
If we have a unary & that takes the address of a variable, do
not force the variable to escape if the unary & does not
escape.
From-SVN: r223100
-rw-r--r-- | gcc/go/gofrontend/expressions.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index e811a8d..05ab42b 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -3668,7 +3668,12 @@ Unary_expression::do_flatten(Gogo* gogo, Named_object*, if (this->op_ == OPERATOR_AND) { - if (this->expr_->var_expression() != NULL) + // If this->escapes_ is false at this point, then it was set to + // false by an explicit call to set_does_not_escape, and the + // value does not escape. If this->escapes_ is true, we may be + // able to set it to false if taking the address of a variable + // that does not escape. + if (this->escapes_ && this->expr_->var_expression() != NULL) { Named_object* var = this->expr_->var_expression()->named_object(); if (var->is_variable()) |