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 A6601385841A for ; Thu, 7 Mar 2024 16:03:07 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A6601385841A Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=ucw.cz Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=kam.mff.cuni.cz ARC-Filter: OpenARC Filter v1.0.0 sourceware.org A6601385841A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.113.20.16 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709827390; cv=none; b=gnZ1FWMFz4iF+S9A2eQaSLujh6ttnTQved4ehhTNe2sOpZdMnyVQlMxhj9e57SwULpr/jxNUweyWxUQMJ4CpB2oijGLYgMnBxrsxtT+teLzNsM8T5tw8UgW8o8PieIoOFLX5T5WYk2dq1YRE5FHwV0U6+zz8Un1upQ9p0SHJSOo= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1709827390; c=relaxed/simple; bh=/1GfWLEpPOBydWE0sqQXemeZFU7N8L4Hk2ClGWC62+Y=; h=DKIM-Signature:Date:From:To:Subject:Message-ID:MIME-Version; b=m+qSJD/oYjYp0tzq3xKyShJvEHDGz4vK2FyUudOE8GakuJMWnMwHqPmvFSZG5NR4LIBKxJa8zNsaFJ1Irf/pzyLnsYEiE3THHObSB0h/GbutRM3iavJFC1igUnaB5Zs9MmNsUflh3Wrojlm289Ce0AEN13GB+G7n1jlSYe6uzkA= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by nikam.ms.mff.cuni.cz (Postfix, from userid 16202) id B58BD28453B; Thu, 7 Mar 2024 17:03:06 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ucw.cz; s=gen1; t=1709827386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=t0vk5elfnMCaGP6MgXxASjQOBgznlcCCHysJrp87CJI=; b=DIYg+6KxVouD9p24rmyL7wCdkFLaNzDFtXb8lkzRfqiGMA5Atp5nEGBhuktbPUcvuCaod8 6qcjF1SUmlgK/HI1pYBmLJNJDL5hRnFS9rnFs4sIRR+Jc1mm78R+JxEGQb6j/mglrdXF+H Vvj9FEPxiD2mDsx75Npu2mH4aLt0p+8= Date: Thu, 7 Mar 2024 17:03:06 +0100 From: Jan Hubicka To: Martin Jambor Cc: GCC Patches Subject: Re: [PATCH] ipa: Avoid excessive removing of SSAs (PR 113757) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-10.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,GIT_PATCH_0,HEADER_FROM_DIFFERENT_DOMAINS,JMQ_SPF_NEUTRAL,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: > On Thu, Feb 08 2024, Martin Jambor wrote: > > Hi, > > > > PR 113757 shows that the code which was meant to debug-reset and > > remove SSAs defined by LHSs of calls redirected to > > __builtin_unreachable can trigger also when speculative > > devirtualization creates a call to a noreturn function (and since it > > is noreturn, it does not bother dealing with its return value). > > > > What is more, it seems that the code handling this case is not really > > necessary. I feel slightly idiotic about this because I have a > > feeling that I added it because of a failing test-case but I can > > neither find the testcase nor a reason why the code in > > cgraph_edge::redirect_call_stmt_to_callee would not be sufficient (it > > turns the SSA name into a default-def, a bit like IPA-SRA, but any > > code dominated by a call to a noreturn is not dangerous when it comes > > to its side-effects). So this patch just removes the handling. > > > > Bootstrapped and tested on x86_64-linux and ppc64le-linux. I have also > > LTO-bootstrapped and LTO-profilebootstrapped the patch on x86_64-linux. > > > > OK for master? > > > > Thanks, > > > > Martin > > > > > > gcc/ChangeLog: > > > > 2024-02-07 Martin Jambor > > > > PR ipa/113757 > > * tree-inline.cc (redirect_all_calls): Remove code adding SSAs to > > id->killed_new_ssa_names. > > > > gcc/testsuite/ChangeLog: > > > > 2024-02-07 Martin Jambor > > > > PR ipa/113757 > > * g++.dg/ipa/pr113757.C: New test. OK, thanks! Honza > > --- > > gcc/testsuite/g++.dg/ipa/pr113757.C | 14 ++++++++++++++ > > gcc/tree-inline.cc | 14 ++------------ > > 2 files changed, 16 insertions(+), 12 deletions(-) > > create mode 100644 gcc/testsuite/g++.dg/ipa/pr113757.C > > > > diff --git a/gcc/testsuite/g++.dg/ipa/pr113757.C b/gcc/testsuite/g++.dg/ipa/pr113757.C > > new file mode 100644 > > index 00000000000..885d4010a10 > > --- /dev/null > > +++ b/gcc/testsuite/g++.dg/ipa/pr113757.C > > @@ -0,0 +1,14 @@ > > +// { dg-do compile } > > +// { dg-options "-O2 -fPIC" } > > +// { dg-require-effective-target fpic } > > + > > +long size(); > > +struct ll { virtual int hh(); }; > > +ll *slice_owner; > > +int ll::hh() { __builtin_exit(0); } > > +int nn() { > > + if (size()) > > + return 0; > > + return slice_owner->hh(); > > +} > > +int (*a)() = nn; > > diff --git a/gcc/tree-inline.cc b/gcc/tree-inline.cc > > index 75c10eb7dfc..cac41b4f031 100644 > > --- a/gcc/tree-inline.cc > > +++ b/gcc/tree-inline.cc > > @@ -2984,23 +2984,13 @@ redirect_all_calls (copy_body_data * id, basic_block bb) > > gimple *stmt = gsi_stmt (si); > > if (is_gimple_call (stmt)) > > { > > - tree old_lhs = gimple_call_lhs (stmt); > > struct cgraph_edge *edge = id->dst_node->get_edge (stmt); > > if (edge) > > { > > if (!id->killed_new_ssa_names) > > id->killed_new_ssa_names = new hash_set (16); > > - gimple *new_stmt > > - = cgraph_edge::redirect_call_stmt_to_callee (edge, > > - id->killed_new_ssa_names); > > - if (old_lhs > > - && TREE_CODE (old_lhs) == SSA_NAME > > - && !gimple_call_lhs (new_stmt)) > > - /* In case of IPA-SRA removing the LHS, the name should have > > - been already added to the hash. But in case of redirecting > > - to builtin_unreachable it was not and the name still should > > - be pruned from debug statements. */ > > - id->killed_new_ssa_names->add (old_lhs); > > + cgraph_edge::redirect_call_stmt_to_callee (edge, > > + id->killed_new_ssa_names); > > > > if (stmt == last && id->call_stmt && maybe_clean_eh_stmt (stmt)) > > gimple_purge_dead_eh_edges (bb); > > -- > > 2.43.0