From patchwork Thu Apr 29 19:33:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Edelsohn X-Patchwork-Id: 1471837 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@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.a=rsa-sha256 header.s=default header.b=EYPyPhQJ; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FWQdq181qz9sj0 for ; Fri, 30 Apr 2021 05:33:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F17D83848405; Thu, 29 Apr 2021 19:33:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F17D83848405 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1619724795; bh=amD7S48sq9wGjpM1JuJqPMijQcjpD2qdOopwziMoGI0=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=EYPyPhQJx5hXFqG9JvBw4YcllR/iy1/YIrSuaFUOQKur0TEF+dIe1uXrgSSp6sEVZ c5mNc2mvAKU6TKXdvoXtiZmtZ36IEwBVaq1Q7Rizp8+pEWGOrkXTh/O9uc8zgVUf24 Y14WhpsIYVSMYTffg/TfV4Xe6VQm77+3fTeHhZy4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-lf1-x136.google.com (mail-lf1-x136.google.com [IPv6:2a00:1450:4864:20::136]) by sourceware.org (Postfix) with ESMTPS id 6D73F3848402 for ; Thu, 29 Apr 2021 19:33:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6D73F3848402 Received: by mail-lf1-x136.google.com with SMTP id x2so639810lff.10 for ; Thu, 29 Apr 2021 12:33:12 -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:cc; bh=amD7S48sq9wGjpM1JuJqPMijQcjpD2qdOopwziMoGI0=; b=JO3gt3jP6/6uI8lYXqodWk6jRKhC4Wxjo3UExkxSCwBYcNkvEewcymq8mvqbBDWWZq 6IUyvIRjuxZTrDh0Pc2QYOpA3STolFsmGb3zXfGTamchb2YyLLeiiBO80hkUS3Worf+v o07z+1EHU8JbLHvNUxcuSsZ/Swlk6uRF7CEoz3satwUAahGhi/r5WuHI7jLrv34E9v1e tvOi19c0KLD+9X63xfuT6yBvtgUdO6Z/BcFGHbW7JVR4mO0ep374ycPOmt/J5zWDrey/ JTGOfsVwZ1y2x5BXCUaSShr8TFWpt6RMGFaer4ar53QbzQZ4DSCL2Y0ERch4wjUAv4/h UjtA== X-Gm-Message-State: AOAM5307hNMqKubvfypweLRuJSgiAmVEIFqCrPKc2R/uJeMoITGiLu7l WFb5l/MyizECAfwsxl8yXdiCllC/6uhOs6fy0UE= X-Google-Smtp-Source: ABdhPJxQM5XAt+n9wZzsZXundiWRhQB9aa1pApOkSmshVxRBU+mFT3xLv8Vr0SNGV3xRRIZUpuCNaAXPWvAccQu2zq8= X-Received: by 2002:ac2:447b:: with SMTP id y27mr734712lfl.217.1619724791143; Thu, 29 Apr 2021 12:33:11 -0700 (PDT) MIME-Version: 1.0 Date: Thu, 29 Apr 2021 15:33:00 -0400 Message-ID: Subject: [PATCH] Disable section anchors for VAR_DECLs if -fdata-sections To: Richard Sandiford X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: David Edelsohn via Gcc-patches From: David Edelsohn Reply-To: David Edelsohn Cc: GCC Patches Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" -fdata-sections places data symbols into their own, unique, named sections. -fsection-anchors create an anchor to access neighboring symbols within a section. When both are enabled, a separate section anchor is created for each symbol, which provides no benefit. This patch updates the common gating function use_blocks_for_decl_p() to return false if -fdata-sections is enabled. Constants still can be placed into object blocks because constants use a separate, different gating function. Bootstrapped on powerpc-ibm-aix7.2.3.0 Okay? Thanks, David gcc/ChangeLog: * varasm.c (use_blocks_for_decl_p): Don't use section anchors for VAR_DECLs if -fdata-sections enabled. diff --git a/gcc/varasm.c b/gcc/varasm.c index 3ecf9e039bb..ac256ef65e5 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -1340,6 +1340,12 @@ use_blocks_for_decl_p (tree decl) { struct symtab_node *snode; + /* Don't create object blocks if each DECL is placed into a separate + section because that will uselessly create a section anchor for + each DECL. */ + if (flag_data_sections) + return false; + /* Only data DECLs can be placed into object blocks. */ if (!VAR_P (decl) && TREE_CODE (decl) != CONST_DECL) return false;