From patchwork Thu Oct 5 23:25:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Lance Taylor X-Patchwork-Id: 822131 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gcc.gnu.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-463585-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="T05QuHKU"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3y7TRN0Rfwz9t45 for ; Fri, 6 Oct 2017 10:26:07 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; q= dns; s=default; b=XNDNMy/+Oqt628lQAlrowMdUXdyHa2Q8ARMdFb6l37UHQJ FG62dYLzDldwHOePBkdXWESa9zKoiYC9wN3lCZ12UiogRdn3T4FI+3FozoUhAUdq 1acLJSGLxTb0W0GIs0Ot5ThadKmr8jRjScSHsF643P5LLXmjqQhn6X+TeKlfs= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :mime-version:from:date:message-id:subject:to:content-type; s= default; bh=7nsW5LVwAVtToE31+VZIrm/+Dcc=; b=T05QuHKU0ZYwlplsowKm 97eOPTuej4TIeN2KwDiH3nwz8f/Ec87QXgthRkL6hK6SPbm97AaHpe071t6nleQu +zJKv7FnZCC7T0QCF3ITjoUIURgwUsaFe5VUsHxDYqcB1Q/w2M8uKTZamC84Xf0a 0vfCgnYfkqwtK9QnumlIdSg= Received: (qmail 52557 invoked by alias); 5 Oct 2017 23:25:58 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 52508 invoked by uid 89); 5 Oct 2017 23:25:58 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-11.1 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_NONE, SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-wm0-f48.google.com Received: from mail-wm0-f48.google.com (HELO mail-wm0-f48.google.com) (74.125.82.48) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 05 Oct 2017 23:25:56 +0000 Received: by mail-wm0-f48.google.com with SMTP id f4so4933435wme.0 for ; Thu, 05 Oct 2017 16:25:56 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=5/uki17c6I/dit7Zq/3rCjT9X5t/lmD9CxXidj3VAl8=; b=h8rKLhy8HnEkls06JN2Ov7CQLGGIqXOIk/vDkBt7yLH31MyfUW5A+UVw/tD6/YQOG7 5Np35o1R8DUprvwCirroK7HNXUiMc1ZMyU+DSY2rzctNHBXI1aKoDWuf2zUAcw+c1OwS wHNEYuCkqNd0M9yaPZaUd1DhHHlqk3qKpszinYD+a4nXoRmohSdue5EX9V/QzYw3hMBu sJjwymBkn+ig5SzoHOGe5U80FqBX4Thqcom+ULKbKIsSTiyT46xSX5VxdUyT0SAmtKTF HAjAIPgkIASsBPml+u5hscolbU2eoRO8CIk8unmfacIlIAAUpDyB/QI2gPHG5q9l1kte xZmg== X-Gm-Message-State: AMCzsaX/aIirOl5nP8E7fjywHxww/kXAj38dGfuZE06WLhOU0p+zaNlV 5QAnyB41lr+PdxADNgTKtcsMjzMZt3iqDLbAs3PAnL6b X-Google-Smtp-Source: AOwi7QB1RmstCxfV6tFmy5BxHj5x+fmHb6ODeB0SR+G2w1PR3P0WAx11MrHh/jgCrvvGMjw2tu4i0ddSJqpMCgTBycU= X-Received: by 10.80.167.37 with SMTP id h34mr731947edc.223.1507245954122; Thu, 05 Oct 2017 16:25:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.80.179.240 with HTTP; Thu, 5 Oct 2017 16:25:53 -0700 (PDT) From: Ian Lance Taylor Date: Thu, 5 Oct 2017 16:25:53 -0700 Message-ID: Subject: Go patch committed: Drop special handling of unexported func/var names To: gcc-patches , "gofrontend-dev@googlegroups.com" This patch to the Go frontend changes the handling of the assembler names used for unexported functions and variables, making them the same as for exported 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. 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 253458) +++ gcc/go/gofrontend/MERGE (working copy) @@ -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. Index: gcc/go/gofrontend/gogo.cc =================================================================== --- gcc/go/gofrontend/gogo.cc (revision 253458) +++ gcc/go/gofrontend/gogo.cc (working copy) @@ -5343,8 +5343,9 @@ Function::get_or_make_decl(Gogo* gogo, N { 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, N 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, N { 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, N 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 Index: gcc/go/gofrontend/gogo.h =================================================================== --- gcc/go/gofrontend/gogo.h (revision 253458) +++ gcc/go/gofrontend/gogo.h (working copy) @@ -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*); Index: gcc/go/gofrontend/names.cc =================================================================== --- gcc/go/gofrontend/names.cc (revision 253458) +++ gcc/go/gofrontend/names.cc (working copy) @@ -54,19 +54,6 @@ Gogo::function_asm_name(const std::strin 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 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);