From patchwork Fri Sep 20 09:10:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Botcazou X-Patchwork-Id: 1987833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=adacore.com header.i=@adacore.com header.a=rsa-sha256 header.s=google header.b=WtQFsmbR; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.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 ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4X96934yn0z1y27 for ; Fri, 20 Sep 2024 19:12:23 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 59119385B508 for ; Fri, 20 Sep 2024 09:12:21 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by sourceware.org (Postfix) with ESMTPS id 74DA83858420 for ; Fri, 20 Sep 2024 09:11:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 74DA83858420 Authentication-Results: sourceware.org; dmarc=pass (p=quarantine dis=none) header.from=adacore.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=adacore.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 74DA83858420 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a00:1450:4864:20::32d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726823521; cv=none; b=fxuhXd/vAwJYsTHspnMkNRvLJ7PD/k/dsF/8b2fcEhmRovMCR8/nZsY6XEeiRhZDh4dvF1qbJE+J3SgRrVPdETHtzWToHfz8otrnGZxhUCZ+rlpUuwq1j9y2T3Fbm8R3Lo7PORQlDAn3ugYXD+eGVhDxvR7mjEPEvc2Rkb8KsFg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1726823521; c=relaxed/simple; bh=84JimFxE5k9avL2l1rumVLnGqIic0NSiYY25AnSzdl0=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=D/MY8wfttXV6K3uT3cca2DuDVW2JOlvZ+hKII8Hy2tMfalZBzbuttmoIXSeexgerdOhCQNnxltRXCLA7STDPeeZUBQADwVRu9cRQj9Kc4afV9wz6PtViyxFdrKjkcFSgFMKEnIqJmI+lpzBRZ/SPqwDiB4ZZ6vw2snnmsGqUSiM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-42cc43454d5so14225365e9.3 for ; Fri, 20 Sep 2024 02:11:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1726823518; x=1727428318; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=FeH66AQbZ7qgeLeB/an2yYWvELCrszWNhgZpfMPEgwE=; b=WtQFsmbRXYshHRra710XsD0ARy4rwHx0PFcUaAWiO36XMm3WuNvYrFRpKFVshfT5Sr 9Nm30OBd3sMzDcyUVFQ/hYGrE06CppuwPcbwK4faps1WBHmjXhYqrf8u3Ake4gnX1MIQ r7YENvV/vVovmfQC9M3yMLJoriGOeTE2OYJdAhe+11qIMrBpq+OjeUxIlNf/i4LBz0IM 1CQ3fbptEFC9s1mWAbZzEh0mRJixWl7LDf7q0T0GSu6d92ASS+QiSZSUQenOWnC74X2y eu8CYVzzLjEuNhDZzadk5/m4WzR8V91M6VcOmkVPdpxuCYKxwSMH0VCMeunUsndYbOP6 EwMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726823518; x=1727428318; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FeH66AQbZ7qgeLeB/an2yYWvELCrszWNhgZpfMPEgwE=; b=kTHIDoJ8NYI3pfN7hBI/GX1n3/l5Vn1Ju9o8N9+oFjE8FfjCGtX0INmhhGewVA4OIg V006qNucD5R5KchpwLE1pYsL/yq1zD4NB8XRDbNL+dcGsT2xsISGEY7v1/niPZlJTZQs rtHuxgCDZPJ0eewnd1Qb4du2H3fdCE1tDiBfHB3pWaZpeLvaep0jgh/NePGNmq8g8mTX L3BvHhH/vOxRtRuCu1dmScQHbALV0xliohPR7W0cShSrJHZroYxL2VsCAViQzsCZT05F WvXGzsbH/CwutDKs3EUvCw2RPIOlEv3swvWS+FvLMhxNKrKxH5TAJyFNFGGrV1j9eqne //TQ== X-Gm-Message-State: AOJu0Yyq1NjOCEz1FkQvlBYO1t9aXkTOBgBu2n10IhMvg7Iy+jVuCqRX gEa3X6DZ5tMWxVeR5IcxQ1NPvUriwKaPXio940k5aAilReo0WRMA0AM8ECz0IgaR1WPCEMNBXCM = X-Google-Smtp-Source: AGHT+IEBeh5RRMau5FVcCNWquVMBjnrRSpV+LlXHLwHXZCa6bJSF78p/9uENaHdNv/PyB3SfAm1aBA== X-Received: by 2002:adf:e548:0:b0:374:c847:859 with SMTP id ffacd0b85a97d-37a42380c94mr1095779f8f.54.1726823517883; Fri, 20 Sep 2024 02:11:57 -0700 (PDT) Received: from fomalhaut.localnet ([2a01:e0a:8d5:d990:e654:e8ff:fe8f:2ce6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-378e72e4b60sm17059554f8f.24.2024.09.20.02.11.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Sep 2024 02:11:57 -0700 (PDT) From: Eric Botcazou X-Google-Original-From: Eric Botcazou To: gcc-patches@gcc.gnu.org Subject: [PATCH] Fix small thinko in IPA mod/ref pass Date: Fri, 20 Sep 2024 11:10:17 +0200 Message-ID: <6084877.lOV4Wx5bFT@fomalhaut> MIME-Version: 1.0 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org Hi, the attached C testcase exhibits a wrong-code regression present since the specific support for the static chain was added to the IPA mod/ref pass (GCC 12 and later) although the underlying issue might have been present before. When a memory copy operation is analyzed by analyze_ssa_name, if both the load and the store are made through the same SSA name, the store is overlooked. Tested on x86-64/Linux, OK for all active branches? 2024-09-20 Eric Botcazou * ipa-modref.cc (modref_eaf_analysis::analyze_ssa_name): Always process both the load and the store of a memory copy operation. 2024-09-20 Eric Botcazou * gcc.dg/ipa/modref-4.c: New test. diff --git a/gcc/ipa-modref.cc b/gcc/ipa-modref.cc index 9275030c254..400a8856de2 100644 --- a/gcc/ipa-modref.cc +++ b/gcc/ipa-modref.cc @@ -2610,8 +2610,9 @@ modref_eaf_analysis::analyze_ssa_name (tree name, bool deferred) is used arbitrarily. */ if (memory_access_to (gimple_assign_rhs1 (assign), name)) m_lattice[index].merge (deref_flags (0, false)); + /* Handle *name = *exp. */ - else if (memory_access_to (gimple_assign_lhs (assign), name)) + if (memory_access_to (gimple_assign_lhs (assign), name)) m_lattice[index].merge_direct_store (); } /* Handle lhs = *name. */