From patchwork Thu Sep 5 06:24:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Pinski X-Patchwork-Id: 97119 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 C831D386482B for ; Thu, 5 Sep 2024 06:24:54 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by sourceware.org (Postfix) with ESMTPS id 405CC3860C34 for ; Thu, 5 Sep 2024 06:24:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 405CC3860C34 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=quicinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=quicinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 405CC3860C34 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725517463; cv=none; b=kyJpkp/JZkTyt0hOHrKD2OpZhrvrBLqWk1lmidXwe5t2uNWTlwsPArIR8ZyaWm8R9TwXQ7QXSXWQ07mBt4ljcJYaMWCbbNorEHw444BtmIrey1SSSqz3jCN9sxoYJWTrIxP4Dfi/b1Bxb7KKXkeSGTW4c1yyemNYo9kTX0onPqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1725517463; c=relaxed/simple; bh=7oMOfKY7UwYV8r4yn/3k9DzFdPt6Bs8/ijGD5mkm83M=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=j2Y8EohCk9jEBQmb1dUFV6y9qWj6mRdMQvJ0Wi+YmFWrPfKgRmbAL4MnQhhvDti8gOxeDuZFHzB5PU6X5zrnyk+2kx1/l61dBXE/5IU4t6r63joLUJ2/uInh5gJJyopyTvE5nv16Kt/XmMCPT2ejJf84va3NJR6Lr1IJphh08a4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 4855i5NG007855 for ; Thu, 5 Sep 2024 06:24:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quicinc.com; h= cc:content-transfer-encoding:content-type:date:from:message-id :mime-version:subject:to; s=qcppdkim1; bh=9KiWvcRZ2SfEFBPQMlvd3E Pod2VTiJb8aRijYSAIgrM=; b=CX5rn/i7FChNrlcR29Gp5QcXct16XRminGcc14 0D48/WBZW/OL0hZHapi+ywJcVHCuT6DzbhtIagxXdjjjgwSTnJdki/d9qCLL0RmM XgR4RmrpR86VA6kCr5PHZPfu3JX4iQNVrO4gCJBlsEakKgU2i4UAh6dp2u/JOnPv VCyNOF/gG1L6LOxvgbQql0hUvujakJ7YkeTnSaHvvH6caAZxd+m8vjht//EaEVFH aJsQnw2w9Ud4hhNBTsZylcNmITshtG7LMmLuddFXd+3UzTT/84TnlZCaKUGfpDz7 uUMcYa6O1IElwEYoapvLQGNzmvPMgbecDj6ixATCLo+xTHXg== Received: from nasanppmta01.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 41f6rng2mh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 05 Sep 2024 06:24:18 +0000 (GMT) Received: from nasanex01c.na.qualcomm.com (nasanex01c.na.qualcomm.com [10.45.79.139]) by NASANPPMTA01.qualcomm.com (8.18.1.2/8.18.1.2) with ESMTPS id 4856OIhK002308 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Thu, 5 Sep 2024 06:24:18 GMT Received: from hu-apinski-lv.qualcomm.com (10.49.16.6) by nasanex01c.na.qualcomm.com (10.45.79.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.9; Wed, 4 Sep 2024 23:24:17 -0700 From: Andrew Pinski To: CC: Andrew Pinski Subject: [PATCH] fab: Cleanup eh after optimize_memcpy [PR116601] Date: Wed, 4 Sep 2024 23:24:06 -0700 Message-ID: <20240905062406.3514615-1-quic_apinski@quicinc.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.49.16.6] X-ClientProxiedBy: nalasex01c.na.qualcomm.com (10.47.97.35) To nasanex01c.na.qualcomm.com (10.45.79.139) X-QCInternal: smtphost X-Proofpoint-Virus-Version: vendor=nai engine=6200 definitions=5800 signatures=585085 X-Proofpoint-GUID: k_oaw9OYfzfiPEnmI_caFKTlhiQK4mVz X-Proofpoint-ORIG-GUID: k_oaw9OYfzfiPEnmI_caFKTlhiQK4mVz X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1039,Hydra:6.0.680,FMLib:17.12.60.29 definitions=2024-09-05_04,2024-09-04_01,2024-09-02_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 lowpriorityscore=0 priorityscore=1501 spamscore=0 suspectscore=0 bulkscore=0 impostorscore=0 mlxscore=0 clxscore=1015 phishscore=0 mlxlogscore=722 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2407110000 definitions=main-2409050045 X-Spam-Status: No, score=-13.5 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_NONE, 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 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~patchwork=sourceware.org@gcc.gnu.org When optimize_memcpy was added in r7-5443-g7b45d0dfeb5f85, a path was added such that a statement was turned into a non-throwing statement and maybe_clean_or_replace_eh_stmt/gimple_purge_dead_eh_edges would not be called for that statement. This adds these calls to that path. Bootstrapped and tested on x86_64-linux-gnu with no regressions. Ok? For the trunk, 14, 13 and 12 branches? PR tree-optimization/116601 gcc/ChangeLog: * tree-ssa-ccp.cc (pass_fold_builtins::execute): Cleanup eh after optimize_memcpy on a mem statement. gcc/testsuite/ChangeLog: * g++.dg/torture/except-2.C: New test. Signed-off-by: Andrew Pinski --- gcc/testsuite/g++.dg/torture/except-2.C | 18 ++++++++++++++++++ gcc/tree-ssa-ccp.cc | 11 +++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 gcc/testsuite/g++.dg/torture/except-2.C diff --git a/gcc/testsuite/g++.dg/torture/except-2.C b/gcc/testsuite/g++.dg/torture/except-2.C new file mode 100644 index 00000000000..d896937a118 --- /dev/null +++ b/gcc/testsuite/g++.dg/torture/except-2.C @@ -0,0 +1,18 @@ +// { dg-do compile } +// { dg-additional-options "-fexceptions -fnon-call-exceptions" } +// PR tree-optimization/116601 + +struct RefitOption { + char subtype; + int string; +} n; +void h(RefitOption); +void k(RefitOption *__val) +{ + try { + *__val = RefitOption{}; + RefitOption __trans_tmp_2 = *__val; + h(__trans_tmp_2); + } + catch(...){} +} diff --git a/gcc/tree-ssa-ccp.cc b/gcc/tree-ssa-ccp.cc index 44711018e0e..3cd385f476b 100644 --- a/gcc/tree-ssa-ccp.cc +++ b/gcc/tree-ssa-ccp.cc @@ -4325,8 +4325,15 @@ pass_fold_builtins::execute (function *fun) if (gimple_code (stmt) != GIMPLE_CALL) { if (gimple_assign_load_p (stmt) && gimple_store_p (stmt)) - optimize_memcpy (&i, gimple_assign_lhs (stmt), - gimple_assign_rhs1 (stmt), NULL_TREE); + { + optimize_memcpy (&i, gimple_assign_lhs (stmt), + gimple_assign_rhs1 (stmt), NULL_TREE); + old_stmt = stmt; + stmt = gsi_stmt (i); + if (maybe_clean_or_replace_eh_stmt (old_stmt, stmt) + && gimple_purge_dead_eh_edges (bb)) + cfg_changed = true; + } gsi_next (&i); continue; }