compiler: if hidden function referenced by inline, don't hide descriptor
Fixes golang/go#33739
Change-Id: I692ff91722d738451015a3e668521df07e9624d7
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/191037
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
diff --git a/go/expressions.cc b/go/expressions.cc
index aa0fda0..0cf1710 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -1560,10 +1560,14 @@
|| 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,
diff --git a/go/gogo.h b/go/gogo.h
index 0abd4b4..4521763 100644
--- a/go/gogo.h
+++ b/go/gogo.h
@@ -1543,6 +1543,11 @@
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()