compiler: export thunks referenced by inline functions
The test case is https://golang.org/cl/248637.
Fixes golang/go#40252
Change-Id: I2ef64275e5c2d27c27b1dd956736a91ef065bf38
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/248638
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 d295fd1..8bbc557 100644
--- a/go/expressions.cc
+++ b/go/expressions.cc
@@ -1635,16 +1635,15 @@
|| 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_referenced_by_inline)
+ && !is_exported_runtime)
|| Gogo::is_thunk(no));
+ if (no->is_function() && no->func_value()->is_referenced_by_inline())
+ is_hidden = false;
+
bvar = context->backend()->immutable_struct(var_name, asm_name,
is_hidden, false,
btype, bloc);
diff --git a/go/gogo.cc b/go/gogo.cc
index 13de74b..82d4c1f 100644
--- a/go/gogo.cc
+++ b/go/gogo.cc
@@ -3370,7 +3370,8 @@
Gogo* gogo_;
};
-// Create a descriptor for every top-level exported function.
+// Create a descriptor for every top-level exported function and every
+// function referenced by an inline function.
int
Create_function_descriptors::function(Named_object* no)
@@ -3378,8 +3379,9 @@
if (no->is_function()
&& no->func_value()->enclosing() == NULL
&& !no->func_value()->is_method()
- && !Gogo::is_hidden_name(no->name())
- && !Gogo::is_thunk(no))
+ && ((!Gogo::is_hidden_name(no->name())
+ && !Gogo::is_thunk(no))
+ || no->func_value()->is_referenced_by_inline()))
no->func_value()->descriptor(this->gogo_, no);
return TRAVERSE_CONTINUE;