diff mbox

gccgo patch committed: If unary & does not escape, variable does not escape

Message ID CAOyqgcV0rCStNTvm+ab9dMz=VFbv3S3L2JxjHKnWWoDO5UYgmA@mail.gmail.com
State New
Headers show

Commit Message

Ian Lance Taylor May 12, 2015, 10:13 p.m. UTC
This patch to the Go frontend notes that if a unary & of a variable
was marked as not escaping, then we don't need to set it to be
escaping based on the variable.  Bootstrapped and ran ran Go testsuite
on x86_64-unknown-linux-gnu.  Committed to mainline.

Ian
diff mbox

Patch

diff -r d50f4d14cfec go/expressions.cc
--- a/go/expressions.cc	Mon May 11 09:18:03 2015 -0700
+++ b/go/expressions.cc	Tue May 12 15:07:53 2015 -0700
@@ -3668,7 +3668,12 @@ 
 
   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())