From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from nikam.ms.mff.cuni.cz (nikam.ms.mff.cuni.cz [195.113.20.16]) by sourceware.org (Postfix) with ESMTPS id 80B003858C60 for ; Sun, 22 Aug 2021 12:38:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 80B003858C60 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=none smtp.mailfrom=kam.mff.cuni.cz Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id 1A5FD2809A8; Sun, 22 Aug 2021 14:38:06 +0200 (CEST) Date: Sun, 22 Aug 2021 14:38:06 +0200 From: Jan Hubicka To: Martin =?iso-8859-2?Q?Li=B9ka?= Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] IPA: MODREF should skip EAF_* flags for indirect calls Message-ID: <20210822123806.GF81418@kam.mff.cuni.cz> References: <7d70a502-f714-77d1-f790-995e245b9ab2@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7d70a502-f714-77d1-f790-995e245b9ab2@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-14.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, KAM_LAZY_DOMAIN_SECURITY, 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-List-Received-Date: Sun, 22 Aug 2021 12:38:08 -0000 > Hello. > > As showed in the PR, returning (EAF_NOCLOBBER | EAF_NOESCAPE) for an argument > that is a function pointer is problematic. Doing such a function call is a clobber. > > Patch can bootstrap on x86_64-linux-gnu and survives regression tests. > > Ready to be installed? > Thanks, > Martin > > PR 101949 > > gcc/ChangeLog: > > * ipa-modref.c (analyze_ssa_name_flags): Do not propagate EAF > flags arguments for indirect functions. > > gcc/testsuite/ChangeLog: > > * gcc.dg/lto/pr101949_0.c: New test. > * gcc.dg/lto/pr101949_1.c: New test. > > Co-Authored-By: Richard Biener > --- > gcc/ipa-modref.c | 3 +++ > gcc/testsuite/gcc.dg/lto/pr101949_0.c | 20 ++++++++++++++++++++ > gcc/testsuite/gcc.dg/lto/pr101949_1.c | 4 ++++ > 3 files changed, 27 insertions(+) > create mode 100644 gcc/testsuite/gcc.dg/lto/pr101949_0.c > create mode 100644 gcc/testsuite/gcc.dg/lto/pr101949_1.c > > diff --git a/gcc/ipa-modref.c b/gcc/ipa-modref.c > index fafd804d4ba..380ba6926b9 100644 > --- a/gcc/ipa-modref.c > +++ b/gcc/ipa-modref.c > @@ -1715,6 +1715,9 @@ analyze_ssa_name_flags (tree name, vec &lattice, int depth, > else if (callee && !ipa && recursive_call_p (current_function_decl, > callee)) > lattice[index].merge (0); > + /* Ignore indirect calls (PR101949). */ > + else if (callee == NULL_TREE) > + lattice[index].merge (0); Thanks for looking into this bug - it is interesting that ipa-pta requires !EAF_NOCLOBBER when function is called... I have some work done on teaching ipa-modref (and other propagation passes) to use ipa-devirt info when the full set of callees is known. This goes oposite way. You can drop flags only when callee == NAME and you can just frop EAF_NOCLOBBER. For example in testcase struct a { void (*foo)(); void *bar; } void wrap (struct a *a) { a->foo (); } will prevent us from figuring out that bar can not be modified when you pass non-ecaping instance of struct a to wrap. Honza