From patchwork Wed Nov 17 21:06:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Hubicka X-Patchwork-Id: 47856 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7EFDB3858410 for ; Wed, 17 Nov 2021 21:09:22 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7EFDB3858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1637183362; bh=G+1nB7D5YDAJgkci88NKo/MsYOdpMrdhrevv6DoqJ/Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=IzLyeu+ASmQC3C4HN5bU4mSKjImxU0yLEcX3gBSSSyayxMys6QRnj3qKUdJy+ZG4o tigDOhmjwKvh6R0j/6xA7C57yF31W/SeRMivH4KlN5ob2topaXemv6Jo1ixXe1uDcu QW/KgPkk75lHsLtXp6AyRURGC9KQ/ZZ/BjrmD5SM= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 4AEB43857C6A for ; Wed, 17 Nov 2021 21:06:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4AEB43857C6A Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 058BC2808BE; Wed, 17 Nov 2021 22:06:48 +0100 (CET) Date: Wed, 17 Nov 2021 22:06:47 +0100 To: gcc-patches@gcc.gnu.org, mjambor@suse.cz Subject: Fix gamess miscompare Message-ID: <20211117210647.GA11052@kam.mff.cuni.cz> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, GIT_PATCH_0, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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: Jan Hubicka via Gcc-patches From: Jan Hubicka Reply-To: Jan Hubicka Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi, this patch fixes bug in streaming in modref access tree that now cause a failure of gamess benchmark. The bug is quite old (present in GCC11 release) but it needs quite interesting series of events to manifest. In particular 1) At lto time ISRA turns some parameters passed by reference to scalar 2) At lto time modref computes summaries for old parameters and then updates them but does so quite stupidly believing that the load from parameters are now unkonwn loads (rather than optimized out). This renders summary not very useful since it thinks every memory aliasing int is now accssed (as opposed as parameter dereference) 3) At stream in we notice too early that summary is useless, set every_access flag and drop the list. However while reading rest of the summary we overwrite the flag back to 0 which makes us to lose part of summary. 4) right selection of partitions needs to be done to avoid late modref from recalculating and thus fixing the summary. This patch fixes the stream in bug, however we also should fix updating of summaries. Martin, would be possible to extend get_original_index by "deref" parameter that would be set to true when refernce was turned to scalar? Bootstrapped/regtested x86_64-linux. Comitted. gcc/ChangeLog: 2021-11-17 Jan Hubicka PR ipa/103246 * ipa-modref.c (read_modref_records): Fix streaminig in of every_access flag. diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c index 9ceecdd479f..c94f0589d44 100644 --- a/gcc/ipa-modref.c +++ b/gcc/ipa-modref.c @@ -3460,10 +3460,10 @@ read_modref_records (lto_input_block *ib, struct data_in *data_in, size_t every_access = streamer_read_uhwi (ib); size_t naccesses = streamer_read_uhwi (ib); - if (nolto_ref_node) - nolto_ref_node->every_access = every_access; - if (lto_ref_node) - lto_ref_node->every_access = every_access; + if (nolto_ref_node && every_access) + nolto_ref_node->collapse (); + if (lto_ref_node && every_access) + lto_ref_node->collapse (); for (size_t k = 0; k < naccesses; k++) {