This patch to the Go frontend checks if a hidden function is
referenced by an inline function when deciding whether to hid the
function descriptor.  This fixes https://golang.org/issue/33739.  The
test case is https://golang.org/cl/191001.  Bootstrapped and ran Go
testsuite on x86_64-pc-linux-gnu.  Committed to mainline.

Ian
Index: gcc/go/gofrontend/MERGE
===================================================================
--- gcc/go/gofrontend/MERGE     (revision 274755)
+++ gcc/go/gofrontend/MERGE     (working copy)
@@ -1,4 +1,4 @@
-1846b07fec2b91facc02ea269f7ab250b30f90b4
+7da359f4659fffff051c05ff442037cfa61febd5
 
 The first line of this file holds the git revision number of the last
 merge done from the gofrontend repository.
Index: gcc/go/gofrontend/expressions.cc
===================================================================
--- gcc/go/gofrontend/expressions.cc    (revision 274755)
+++ gcc/go/gofrontend/expressions.cc    (working copy)
@@ -1560,10 +1560,14 @@ Func_descriptor_expression::do_get_backe
              || no->name().find("equal") != std::string::npos))
        is_exported_runtime = true;
 
+      bool is_referenced_by_inline =
+       no->is_function() && no->func_value()->is_referenced_by_inline();
+
       bool is_hidden = ((no->is_function()
                         && no->func_value()->enclosing() != NULL)
                        || (Gogo::is_hidden_name(no->name())
-                           && !is_exported_runtime)
+                           && !is_exported_runtime
+                           && !is_referenced_by_inline)
                        || Gogo::is_thunk(no));
 
       bvar = context->backend()->immutable_struct(var_name, asm_name,
Index: gcc/go/gofrontend/gogo.h
===================================================================
--- gcc/go/gofrontend/gogo.h    (revision 274755)
+++ gcc/go/gofrontend/gogo.h    (working copy)
@@ -1543,6 +1543,11 @@ class Function
   set_is_inline_only()
   { this->is_inline_only_ = true; }
 
+  // Report whether the function is referenced by an inline body.
+  bool
+  is_referenced_by_inline() const
+  { return this->is_referenced_by_inline_; }
+
   // Mark the function as referenced by an inline body.
   void
   set_is_referenced_by_inline()

Reply via email to