From patchwork Sat Apr 13 18:48:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1085201 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-499224-incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=netcologne.de Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b="jT/M9ohs"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="IqG81xTh"; 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 44hP1Q3hdBz9s5c for ; Sun, 14 Apr 2019 04:48:50 +1000 (AEST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=q9MraJWWNutKRvq9SjLvmNZFAkKJji81CANNvMhbZ0bw4WKRRd 9H5XzdgBHbYWWkZm2LA0TVA4c1a05Rn2sZz79uiIwt0RbQk6yhcxJ0jtizxHSfk7 ectkGzKO9E5d1ykd7tX/Wpk368yJnIdDwuWSzC+JfmKYPQ3Ku9M/hT/GY= 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:to :from:subject:message-id:date:mime-version:content-type; s= default; bh=SwTPp7f/6LiY1fu7kE3yg5g1WtQ=; b=jT/M9ohsW4zymJEPLgF5 CMvfg/UYEdmp2zn8YUR92v8Cvzyx+1IAMXPq7RaNur4XnW+/NPNwhn5Xg6loJsS/ x1VsEHs4LlaJspKXFTFBAWIYuYYfsDeCYxyusXEdS/0LoHmoy9fd8q07fsBxAPoF lCOVQ4vbyvKvC3oXBVr8H4I= Received: (qmail 9299 invoked by alias); 13 Apr 2019 18:48:43 -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 9150 invoked by uid 89); 13 Apr 2019 18:48:36 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-11.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_ASCII_DIVIDERS, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.1 spammy=H*Ad:U*tkoenig, varasmc, varasm.c, UD:varasm.c X-HELO: cc-smtpout3.netcologne.de Received: from cc-smtpout3.netcologne.de (HELO cc-smtpout3.netcologne.de) (89.1.8.213) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 13 Apr 2019 18:48:34 +0000 Received: from cc-smtpin1.netcologne.de (cc-smtpin1.netcologne.de [89.1.8.201]) by cc-smtpout3.netcologne.de (Postfix) with ESMTP id D1DC81258C; Sat, 13 Apr 2019 20:48:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1555181308; bh=doS0eSP6GKuYxhqUxhywk0z0/71J2IZ5SV/aY12Or/k=; h=To:From:Subject:Message-ID:Date:From; b=IqG81xTh4HFfd8PIKOCbgOU2mucSWERP+W8/wQoBxrJNpeMmlW3+EJYwOQvD9SDjZ HNk+hDEmdbACFamnBhdwSJSQdrBY7qIRM3IwdttRLEbVGumvDFJ9va5UrfcqDhG1BQ 4gettUbGK5y5ZjOTGavBG8Y+9sGcvdVygWRZNoOcrAMCU8OnwzRzwR1RCmpvRbQP4Y 2JR38B4VvhNobaV4C8uvFXTjk5tG7te/TWWOnUljnzCA4l0McI7R+3v9gqRQODv+Bt 6owCs8KL2iMky3mpHicQOSug2yE+3krTDyA6minwikYElZH+bKgUr4HH4jJNBNo8GE FnvCHJnfZw+NA== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin1.netcologne.de (Postfix) with ESMTP id C45E111F1E; Sat, 13 Apr 2019 20:48:28 +0200 (CEST) Received: from [2001:4dd7:fc41:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin1.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5cb22efc-0165-7f0000012729-7f000001e27c-1 for ; Sat, 13 Apr 2019 20:48:28 +0200 Received: from [IPv6:2001:4dd7:fc41:0:7285:c2ff:fe6c:992d] (2001-4dd7-fc41-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd7:fc41:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin1.netcologne.de (Postfix) with ESMTPSA; Sat, 13 Apr 2019 20:48:26 +0200 (CEST) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch] Fix PR 84487, large rodata increase in tonto and other programs Message-ID: <9dcba167-4fa0-7c7e-aee4-74a29a8b32cb@netcologne.de> Date: Sat, 13 Apr 2019 20:48:25 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Hello world, the attached patch fixes a 8/9 regression where _def_init, an internal Fortran variable containing only zeros, was placed into the .rodata section. This led to a large increase in executable size. There should be no impact on other languages because the change to varasm.c is guarded by lang_GNU_Fortran (). Regarding the test case: I did find one other test which checks for .bss, so I suppose this is safe. Regression-tested with a full test (--enable-languages=all and make -j64 -k check) on POWER9. I would like to apply it to both affected branches. OK for the general and the Fortran part? Regards Thomas 2019-04-13 Thomas Koenig PR fortran/84487 * trans-decl.c (gfc_get_symbol_decl): Mark _def_init as artificial. 2019-04-13 Thomas Koenig PR fortran/84487 * varasm.c (bss_initializer_p): If we are compiling Fortran, the decl is artifical and it has a size larger than 255, it can be put into BSS. 2019-04-13 Thomas Koenig PR fortran/84487 * gfortran.dg/def_init_1.f90: New test. Index: fortran/trans-decl.c =================================================================== --- fortran/trans-decl.c (Revision 270182) +++ fortran/trans-decl.c (Arbeitskopie) @@ -1865,7 +1865,10 @@ gfc_get_symbol_decl (gfc_symbol * sym) if (sym->attr.vtab || (sym->name[0] == '_' && gfc_str_startswith (sym->name, "__def_init"))) - TREE_READONLY (decl) = 1; + { + TREE_READONLY (decl) = 1; + DECL_ARTIFICIAL (decl) = 1; + } return decl; } Index: varasm.c =================================================================== --- varasm.c (Revision 270182) +++ varasm.c (Arbeitskopie) @@ -1007,9 +1007,13 @@ decode_reg_name (const char *name) bool bss_initializer_p (const_tree decl, bool named) { - /* Do not put non-common constants into the .bss section, they belong in - a readonly section, except when NAMED is true. */ - return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named) + /* Do not put non-common constants into the .bss section, they + belong in a readonly section, except when NAMED is true or when + we are dealing with an artificial declaration, in the Fortran + compiler only, above a certain size. */ + return ((!TREE_READONLY (decl) || DECL_COMMON (decl) || named + || (lang_GNU_Fortran () && DECL_ARTIFICIAL (decl) + && (tree_to_uhwi (DECL_SIZE_UNIT (decl)) > 255 ))) && (DECL_INITIAL (decl) == NULL /* In LTO we have no errors in program; error_mark_node is used to mark offlined constructors. */