From patchwork Sat Nov 2 09:38:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Koenig X-Patchwork-Id: 1188312 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=209.132.180.131; helo=sourceware.org; envelope-from=gcc-patches-return-512261-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="uWFEuN7F"; dkim=pass (2048-bit key; unprotected) header.d=netcologne.de header.i=@netcologne.de header.b="ZjaWDQ48"; 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 474vC14c5Gz9sNx for ; Sat, 2 Nov 2019 20:38:51 +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:to :from:subject:message-id:date:mime-version:content-type; q=dns; s=default; b=KecsivCwppEOZpsCBI2s/jM+O/pC/kkF9OrLSqyPddbuSefWuE KcthPDK4cwBSY2CcNihxyUj8VCZxnH+3RTTUlkkyn1/Zg4ErVDtQTyqoqunOisJp oj6LTwkK5gfH3VfmpHckB6LbG9TpPb4kNzzojmPboYEsOUtfjmMNriFt8= 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=uExe+pNrqfYYmXRQ+TESc+T1pQA=; b=uWFEuN7FBDVFA+l9gUwL 6K+BRNaQ1opYyNKAk5i2r1o37dJYYbuhAS9xVfD7WwuJj1XOb2lzafkVhw//Re/r r4ZEBYZmOq+tQPdXjyQDGBqFMjlhGfAAVhwMDVAt9boUproz7nY26o2Lw0vjjjS5 oDZHFCSD1Q4Ep5nZDP0zyOU= Received: (qmail 25664 invoked by alias); 2 Nov 2019 09:38:40 -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 25648 invoked by uid 89); 2 Nov 2019 09:38:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-10.8 required=5.0 tests=BAYES_00, GIT_PATCH_2, GIT_PATCH_3, KAM_NUMSUBJECT, RCVD_IN_DNSWL_LOW, RCVD_IN_RP_RNBL, SPF_PASS autolearn=ham version=3.3.1 spammy=beast, strange X-HELO: cc-smtpout1.netcologne.de Received: from cc-smtpout1.netcologne.de (HELO cc-smtpout1.netcologne.de) (89.1.8.211) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sat, 02 Nov 2019 09:38:38 +0000 Received: from cc-smtpin3.netcologne.de (cc-smtpin3.netcologne.de [89.1.8.203]) by cc-smtpout1.netcologne.de (Postfix) with ESMTP id 4B36F133B7; Sat, 2 Nov 2019 10:38:35 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=netcologne.de; s=nc1116a; t=1572687515; bh=Izw2Y5DKCbkGK+k3gCuFKZWh3CdMzCN4ngcSLP5NdMQ=; h=To:From:Subject:Message-ID:Date:From; b=ZjaWDQ48czRqBR9dH6YEazy4MDVgYGGF4tfsVf87uep+y3434yS/oNrdBF4iMFZ7J 3ZmEvoF0Xwz/Qk9My3mQfL1hKlbWDyb2blMHj8XIVBRlJ6iq3Ja+0ucO87Fnpt7ZzW ddEx6238M8+6zpccp3g9/YyIu637JLlHx9RMi6P7CFZR2GqUhOK9wxptKuQ0jVoJ/O 1XLaOA0yZxSoCcaYWPaXV0xWayX0jU4kKTV2i8JuEDGqAoH1dFGn+W8TPhowFv6f5h oQrvqdEm2oN4lxHkWIJ/vYnS+DkTsZvlL48naMtr4YuwVKMPtqnZ7yuhRyEjtMrmz7 M3nmmY50AybQw== Received: from localhost (localhost [127.0.0.1]) by cc-smtpin3.netcologne.de (Postfix) with ESMTP id 3CCEB11ECF; Sat, 2 Nov 2019 10:38:35 +0100 (CET) Received: from [2001:4dd4:c133:0:7285:c2ff:fe6c:992d] (helo=cc-smtpin3.netcologne.de) by localhost with ESMTP (eXpurgate 4.6.0) (envelope-from ) id 5dbd4e9b-388c-7f0000012729-7f000001d0c4-1 for ; Sat, 02 Nov 2019 10:38:35 +0100 Received: from [IPv6:2001:4dd4:c133:0:7285:c2ff:fe6c:992d] (2001-4dd4-c133-0-7285-c2ff-fe6c-992d.ipv6dyn.netcologne.de [IPv6:2001:4dd4:c133:0:7285:c2ff:fe6c:992d]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by cc-smtpin3.netcologne.de (Postfix) with ESMTPSA; Sat, 2 Nov 2019 10:38:32 +0100 (CET) To: "fortran@gcc.gnu.org" , gcc-patches From: Thomas Koenig Subject: [patch, fortran] Fix PR 92113 Message-ID: <2fcc0cd7-be3e-8a5c-d742-589312a30eae@netcologne.de> Date: Sat, 2 Nov 2019 10:38:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.7.2 MIME-Version: 1.0 Hello world, the attached patch fixes an 8/9/10 regression where, to fix PR 84487 by not putting the initializers and vtabs into the read-only section (for reasons of size, which could grow enormously) led to a regression on POWER9 and other non-x86 architectures, where the initializer was sometimes optimized away, depending on optimization levels. This was a strange beast to hunt down. This only showed up on the testresults for gcc 8, so I tried to find out what commit had fixed this on trunk, in order to backport. However, bisecting this I found that the test case actually segfaults all the way up to current trunk when run by hand. By running the testsuite, I didn't see it. This is strange, and raises some issues about the testsuite and the possibility of a latent issue, but I lack the knowledge to hunt this down. In the meantime, here is this patch, which puts the vtabs and the initializers where the user actually specified something into the read-only section again. Test case: Well, theoretically it is already there, so it makes little sense to add a new one. Regression-tested on powerpc64le-unknown-linux-gnu, also verified by hand that pr51434.f90 now passes with -O2 there. OK for trunk/9/8? Regards Thomas 2019-11-02 Thomas Koenig PR fortran/92133 * trans-decl.c (gfc_get_symbol_decl): If __def_init actually contains a value, put it into the read-only section. Index: trans-decl.c =================================================================== --- trans-decl.c (Revision 277486) +++ trans-decl.c (Arbeitskopie) @@ -1911,14 +1911,19 @@ gfc_get_symbol_decl (gfc_symbol * sym) if (sym->attr.associate_var) GFC_DECL_ASSOCIATE_VAR_P (decl) = 1; - /* We no longer mark __def_init as read-only so it does not take up - space in the read-only section and dan go into the BSS instead, - see PR 84487. Marking this as artificial means that OpenMP will - treat this as predetermined shared. */ - if (sym->attr.vtab - || (sym->name[0] == '_' && gfc_str_startswith (sym->name, "__def_init"))) - DECL_ARTIFICIAL (decl) = 1; + /* We only mark __def_init as read-only if it actually has an + initializer so it does not needlessly take up space in the + read-only section and can go into the BSS instead, see PR 84487. + Marking this as artificial means that OpenMP will treat this as + predetermined shared. */ + if (sym->attr.vtab || gfc_str_startswith (sym->name, "__def_init")) + { + DECL_ARTIFICIAL (decl) = 1; + if (sym->attr.vtab || sym->value) + TREE_READONLY (decl) = 1; + } + return decl; }