compiler: make non-escaping Bound_method_expression not heap allocate
authorIan Lance Taylor <ian@gcc.gnu.org>
Tue, 9 Jan 2018 23:33:49 +0000 (23:33 +0000)
committerIan Lance Taylor <ian@gcc.gnu.org>
Tue, 9 Jan 2018 23:33:49 +0000 (23:33 +0000)
    Bound_method_expression needs a closure. Stack allocate the
    closure when it does not escape.

    Reviewed-on: https://go-review.googlesource.com/85638

From-SVN: r256407

gcc/go/gofrontend/MERGE
gcc/go/gofrontend/expressions.cc

index b3f314a967cd2115875001a15b05245ddfd05d48..fe3c16e2fe6cd0b48eb92596d28e22159ddeeb78 100644 (file)
@@ -1,4 +1,4 @@
-584fdecefce831c3471dbd4857ba0ce0be2b5212
+d5774539b17112d9ce709a1fe722daf68eb8594f
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
index 319fc9e693474c812e4e051538280bb59cec4430..f4dc8e8b43d3434e6430a3e2d5a47b05b78bf3e4 100644 (file)
@@ -7030,7 +7030,12 @@ Bound_method_expression::do_flatten(Gogo* gogo, Named_object*,
   Expression* ret = Expression::make_struct_composite_literal(st, vals, loc);
 
   if (!gogo->compiling_runtime() || gogo->package_name() != "runtime")
-    ret = Expression::make_heap_expression(ret, loc);
+    {
+      ret = Expression::make_heap_expression(ret, loc);
+      Node* n = Node::make_node(this);
+      if ((n->encoding() & ESCAPE_MASK) == Node::ESCAPE_NONE)
+        ret->heap_expression()->set_allocate_on_stack();
+    }
   else
     {
       // When compiling the runtime, method closures do not escape.