Commit 098d773e by Ian Lance Taylor

compiler: drop special handling of unexported func/var assembler names

    
    For example, for the package math/big, we used to generate unexported
    names as `big.trim` and exported names as `math_big.NewInt`.  After
    this change we will use `math_big` consistently.
    
    Reviewed-on: https://go-review.googlesource.com/68651

From-SVN: r253468
parent b8888a0f
048914caa26b34eebabd0423ed48ee3ac34c919c adc6eb826f156d0980f0ad9f9efc5c919ec4905e
The first line of this file holds the git revision number of the last The first line of this file holds the git revision number of the last
merge done from the gofrontend repository. merge done from the gofrontend repository.
...@@ -5343,8 +5343,9 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) ...@@ -5343,8 +5343,9 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no)
{ {
if (this->fndecl_ == NULL) if (this->fndecl_ == NULL)
{ {
std::string asm_name;
bool is_visible = false; bool is_visible = false;
bool is_init_fn = false;
Type* rtype = NULL;
if (no->package() != NULL) if (no->package() != NULL)
; ;
else if (this->enclosing_ != NULL || Gogo::is_thunk(no)) else if (this->enclosing_ != NULL || Gogo::is_thunk(no))
...@@ -5355,7 +5356,7 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) ...@@ -5355,7 +5356,7 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no)
else if (no->name() == gogo->get_init_fn_name()) else if (no->name() == gogo->get_init_fn_name())
{ {
is_visible = true; is_visible = true;
asm_name = no->name(); is_init_fn = true;
} }
else if (Gogo::unpack_hidden_name(no->name()) == "main" else if (Gogo::unpack_hidden_name(no->name()) == "main"
&& gogo->is_main_package()) && gogo->is_main_package())
...@@ -5368,17 +5369,29 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) ...@@ -5368,17 +5369,29 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no)
{ {
if (!this->is_unnamed_type_stub_method_) if (!this->is_unnamed_type_stub_method_)
is_visible = true; is_visible = true;
Type* rtype = NULL;
if (this->type_->is_method()) if (this->type_->is_method())
rtype = this->type_->receiver()->type(); rtype = this->type_->receiver()->type();
asm_name = gogo->function_asm_name(no->name(), NULL, rtype);
} }
std::string asm_name;
if (!this->asm_name_.empty()) if (!this->asm_name_.empty())
{ {
asm_name = this->asm_name_; asm_name = this->asm_name_;
// If an assembler name is explicitly specified, there must
// be some reason to refer to the symbol from a different
// object file.
is_visible = true; is_visible = true;
} }
else if (is_init_fn)
{
// These names appear in the export data and are used
// directly in the assembler code. If we change this here
// we need to change Gogo::init_imports.
asm_name = no->name();
}
else
asm_name = gogo->function_asm_name(no->name(), NULL, rtype);
// If a function calls the predeclared recover function, we // If a function calls the predeclared recover function, we
// can't inline it, because recover behaves differently in a // can't inline it, because recover behaves differently in a
...@@ -5409,10 +5422,6 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) ...@@ -5409,10 +5422,6 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no)
if ((this->pragmas_ & GOPRAGMA_NOSPLIT) != 0) if ((this->pragmas_ & GOPRAGMA_NOSPLIT) != 0)
disable_split_stack = true; disable_split_stack = true;
// Encode name if asm_name not already set at this point
if (asm_name.empty())
asm_name = gogo->unexported_function_asm_name(no->name());
// This should go into a unique section if that has been // This should go into a unique section if that has been
// requested elsewhere, or if this is a nointerface function. // requested elsewhere, or if this is a nointerface function.
// We want to put a nointerface function into a unique section // We want to put a nointerface function into a unique section
......
...@@ -767,10 +767,6 @@ class Gogo ...@@ -767,10 +767,6 @@ class Gogo
function_asm_name(const std::string& go_name, const Package*, function_asm_name(const std::string& go_name, const Package*,
const Type* receiver); const Type* receiver);
// Return the assembler name to use for an unexported function.
std::string
unexported_function_asm_name(const std::string& go_name);
// Return the name to use for a function descriptor. // Return the name to use for a function descriptor.
std::string std::string
function_descriptor_name(Named_object*); function_descriptor_name(Named_object*);
......
...@@ -54,19 +54,6 @@ Gogo::function_asm_name(const std::string& go_name, const Package* package, ...@@ -54,19 +54,6 @@ Gogo::function_asm_name(const std::string& go_name, const Package* package,
return go_encode_id(ret); return go_encode_id(ret);
} }
// Return the assembler name to use for an unexported function.
// FIXME: This should probably be removed and the callers changed to
// simply call function_name.
std::string
Gogo::unexported_function_asm_name(const std::string& go_name)
{
std::string ret = this->package_name();
ret.append(1, '.');
ret.append(Gogo::unpack_hidden_name(go_name));
return go_encode_id(ret);
}
// Return the name to use for a function descriptor. These symbols // Return the name to use for a function descriptor. These symbols
// are globally visible. // are globally visible.
...@@ -171,16 +158,7 @@ Gogo::specific_type_function_names(const Type* type, const Named_type* name, ...@@ -171,16 +158,7 @@ Gogo::specific_type_function_names(const Type* type, const Named_type* name,
std::string std::string
Gogo::global_var_asm_name(const std::string& go_name, const Package* package) Gogo::global_var_asm_name(const std::string& go_name, const Package* package)
{ {
// FIXME: Using package_name for hidden names and pkgpath_symbol for std::string ret = (package != NULL
// non-hidden names doesn't make sense, but it dates back to the
// first public commit of the gofrontend repo.
std::string ret;
if (Gogo::is_hidden_name(go_name))
ret = (package != NULL
? package->package_name()
: this->package_name());
else
ret = (package != NULL
? package->pkgpath_symbol() ? package->pkgpath_symbol()
: this->pkgpath_symbol()); : this->pkgpath_symbol());
ret.push_back('.'); ret.push_back('.');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment