From: Ian Lance Taylor Date: Thu, 5 Oct 2017 23:25:51 +0000 (+0000) Subject: compiler: drop special handling of unexported func/var assembler names X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=098d773ec718ef861119ca821337ab2fcfb17af2;p=gcc.git 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 --- diff --git a/gcc/go/gofrontend/MERGE b/gcc/go/gofrontend/MERGE index 3e33c626cc8..acb1d9584a3 100644 --- a/gcc/go/gofrontend/MERGE +++ b/gcc/go/gofrontend/MERGE @@ -1,4 +1,4 @@ -048914caa26b34eebabd0423ed48ee3ac34c919c +adc6eb826f156d0980f0ad9f9efc5c919ec4905e The first line of this file holds the git revision number of the last merge done from the gofrontend repository. diff --git a/gcc/go/gofrontend/gogo.cc b/gcc/go/gofrontend/gogo.cc index da8f3c584eb..c986963f1b2 100644 --- a/gcc/go/gofrontend/gogo.cc +++ b/gcc/go/gofrontend/gogo.cc @@ -5343,8 +5343,9 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) { if (this->fndecl_ == NULL) { - std::string asm_name; bool is_visible = false; + bool is_init_fn = false; + Type* rtype = NULL; if (no->package() != NULL) ; else if (this->enclosing_ != NULL || Gogo::is_thunk(no)) @@ -5355,7 +5356,7 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) else if (no->name() == gogo->get_init_fn_name()) { is_visible = true; - asm_name = no->name(); + is_init_fn = true; } else if (Gogo::unpack_hidden_name(no->name()) == "main" && gogo->is_main_package()) @@ -5368,17 +5369,29 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) { if (!this->is_unnamed_type_stub_method_) is_visible = true; - Type* rtype = NULL; if (this->type_->is_method()) rtype = this->type_->receiver()->type(); - asm_name = gogo->function_asm_name(no->name(), NULL, rtype); } + std::string asm_name; if (!this->asm_name_.empty()) { 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; } + 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 // can't inline it, because recover behaves differently in a @@ -5409,10 +5422,6 @@ Function::get_or_make_decl(Gogo* gogo, Named_object* no) if ((this->pragmas_ & GOPRAGMA_NOSPLIT) != 0) 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 // requested elsewhere, or if this is a nointerface function. // We want to put a nointerface function into a unique section diff --git a/gcc/go/gofrontend/gogo.h b/gcc/go/gofrontend/gogo.h index 018aca5e2ef..345a15df570 100644 --- a/gcc/go/gofrontend/gogo.h +++ b/gcc/go/gofrontend/gogo.h @@ -767,10 +767,6 @@ class Gogo function_asm_name(const std::string& go_name, const Package*, 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. std::string function_descriptor_name(Named_object*); diff --git a/gcc/go/gofrontend/names.cc b/gcc/go/gofrontend/names.cc index 48ffec08d9e..20f7c57ee49 100644 --- a/gcc/go/gofrontend/names.cc +++ b/gcc/go/gofrontend/names.cc @@ -54,19 +54,6 @@ Gogo::function_asm_name(const std::string& go_name, const Package* package, 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 // are globally visible. @@ -171,18 +158,9 @@ Gogo::specific_type_function_names(const Type* type, const Named_type* name, std::string Gogo::global_var_asm_name(const std::string& go_name, const Package* package) { - // FIXME: Using package_name for hidden names and pkgpath_symbol for - // 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() - : this->pkgpath_symbol()); + std::string ret = (package != NULL + ? package->pkgpath_symbol() + : this->pkgpath_symbol()); ret.push_back('.'); ret.append(Gogo::unpack_hidden_name(go_name)); return go_encode_id(ret);