From patchwork Fri Jul 29 08:47:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 300 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:b5d6:b0:2b9:3548:2db5 with SMTP id v22csp691980pxt; Fri, 29 Jul 2022 01:47:46 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vAodMerv7TU/1T1zmviE+6cpEqok2d0hkjR3fWw1b+kclCEL3zKTpTNVu+xYr1ubkzz1qR X-Received: by 2002:a05:6402:1c01:b0:43a:f714:bcbe with SMTP id ck1-20020a0564021c0100b0043af714bcbemr2585374edb.14.1659084466590; Fri, 29 Jul 2022 01:47:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659084466; cv=none; d=google.com; s=arc-20160816; b=vEpkI405WnAAo11GJFkgnXYF7AM0vq0CWY7RW1wQnc7U/WR5R42jDPWqIlb6f0p8lm YNrGA9MTscgi4mSmaHrgUpCxigutKatZJpQK4p/+Od7phWPPcbUoNqPiXYFg7cTTHJ+L WkW8p4Wnrxf9uPX2pCMptoj9BFCv29+Egc0Xs4awFGfNMR0vYAEcJGmLJOkW+i02EieN hAbrkgmqoZyp0HAYihGY58nl9eacqjqQi8XxbReZIKMi7/b8VHhK1KW3BjCe0bfd+XL7 Eb4Edin8MDJgL1Uvd40p/mXDIAkBH7VJkfraxkhhpHK+FbN5ArIe88wrPKip5QXWnwPi 4sHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=PXn1qn2zt8+QJP/btt4uGRLsS3V00Z0b82sEe3BW9xg=; b=PTHpBI+MiZbG+BukC6tMNtMqgUdYAzQYbqmnfmAvhl2+5T0W9rOgOtX2/CJYGnLNWs CYyuIuSCkNRPn2BbByiERARJYREQGycffJf15FYDr+zIaV9wWRN2OfHpldQRXmWVwJ+U GuORfQ7Z17m/Zr+2KBBdn7qytoQRWo9MwWDbJYebxj2amTYW3zuQFKU/yCYkErAGn3vT SCGcqS5ml+Vxjcx94rIFEqSCQ9nVSVFDVfu84zZgH0aM1szhMC1rTOCyRSrkLiqUOssM DyXL8JfF0ti4eGPsL821RZwt/2CAIaSOI+MwDvz8pEBcrDKYPdNGwUoxcm7w8MlD/O+y DQPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gZagWo3+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id b22-20020aa7cd16000000b0043bbc04ccd6si1081722edw.398.2022.07.29.01.47.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Jul 2022 01:47:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=gZagWo3+; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 7D03338582AA for ; Fri, 29 Jul 2022 08:47:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7D03338582AA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1659084465; bh=PXn1qn2zt8+QJP/btt4uGRLsS3V00Z0b82sEe3BW9xg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=gZagWo3+y2eRdE6kn8FVGeHUWDRea5NbxgcSHokk+6dJR2uLXQGABhThZjgE2OeTQ 1L03s1mcCraQmYWtttE1cM2SYz/n8yDYOyPVl13fXIkL2BpwHwl26DsLZ+PfYKoN0l ezAqeVdbqiJl9orZFGxbcAvcKsxHT05YytMfKDM4= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id 0A09F385840A for ; Fri, 29 Jul 2022 08:47:03 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0A09F385840A Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id D3AA3208EA for ; Fri, 29 Jul 2022 08:47:01 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id C077113A1B for ; Fri, 29 Jul 2022 08:47:01 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id vPXQLYWe42IPUQAAMHmgww (envelope-from ) for ; Fri, 29 Jul 2022 08:47:01 +0000 Date: Fri, 29 Jul 2022 10:47:01 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/106422 - verify block copying in forward threading MIME-Version: 1.0 Message-Id: <20220729084701.C077113A1B@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1739676153545812767?= X-GMAIL-MSGID: =?utf-8?q?1739676153545812767?= The forward threader failed to check whether it can actually duplicate blocks. The following adds this in a similar place the backwards threader performs this check. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/106422 * tree-ssa-threadupdate.cc (fwd_jt_path_registry::update_cfg): Check whether we can copy thread blocks and cancel the thread if not. * gcc.dg/torture/pr106422.c: New testcase. --- gcc/testsuite/gcc.dg/torture/pr106422.c | 14 ++++++++++++++ gcc/tree-ssa-threadupdate.cc | 4 +++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr106422.c diff --git a/gcc/testsuite/gcc.dg/torture/pr106422.c b/gcc/testsuite/gcc.dg/torture/pr106422.c new file mode 100644 index 00000000000..a2cef1aecb6 --- /dev/null +++ b/gcc/testsuite/gcc.dg/torture/pr106422.c @@ -0,0 +1,14 @@ +/* { dg-do compile } */ + +void vfork() __attribute__((__leaf__)); +void semanage_reload_policy(char *arg, void cb(void)) +{ + if (!arg) + { + cb(); + return; + } + vfork(); + if (arg) + __builtin_free(arg); +} diff --git a/gcc/tree-ssa-threadupdate.cc b/gcc/tree-ssa-threadupdate.cc index f901c7759e3..0f2b319d44a 100644 --- a/gcc/tree-ssa-threadupdate.cc +++ b/gcc/tree-ssa-threadupdate.cc @@ -2678,7 +2678,9 @@ fwd_jt_path_registry::update_cfg (bool may_peel_loop_headers) for (j = 0; j < path->length (); j++) { edge e = (*path)[j]->e; - if (m_removed_edges->find_slot (e, NO_INSERT)) + if (m_removed_edges->find_slot (e, NO_INSERT) + || ((*path)[j]->type == EDGE_COPY_SRC_BLOCK + && !can_duplicate_block_p (e->src))) break; }