From patchwork Thu Oct 19 07:58:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Oliva X-Patchwork-Id: 155358 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2010:b0:403:3b70:6f57 with SMTP id fe16csp224431vqb; Thu, 19 Oct 2023 00:59:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEasRbqC+lpsgYv3MUZ9PV4Mvh5qB3CoXxiUwkLhXZr+TL4//TJFJMQ3I1NPvztTPzZGuTC X-Received: by 2002:a05:622a:30b:b0:417:f9a4:b169 with SMTP id q11-20020a05622a030b00b00417f9a4b169mr1627922qtw.26.1697702364719; Thu, 19 Oct 2023 00:59:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1697702364; cv=pass; d=google.com; s=arc-20160816; b=F0gUkbaax5EBHt1y4tJ8o0KNTM5r9UepMosf/WCAWN/BStHTgErbFksnwBGpN5KWtK BZk/jY0rXCOW+xUouNBjAEqijCyvTno29RBA35sO8E6HOinysAsdvkCxZWXUiT9KVhYN FGmmSzvsTSYZdj4QL/SnBtTvfQaqyjt9B57mtsXDydROaABBW0ndbPaVsey0h/ENaA4V kGGbDOjqhCC5/DM+lZFU6o4FNNk54PeH5h5Ov8a6r/+nP2fqyO/3etvU9CDdE/6w2hQe vIXqqhkidg7E51X6QxMBxSjvBSW8b7giPgWrsHqp1DqCyDQc4nfz1T9q5qgcvDDLa66l eNDw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version:user-agent :message-id:date:organization:subject:cc:to:from:dkim-signature :arc-filter:dmarc-filter:delivered-to; bh=5zMYe+PRBqEExgMRKXKcv0iTQrCnpE2qQyBIKd8Io1M=; fh=BYjcaNCYGJOL4+GLz83yzrka98SZX7mVbmKdSR/R2Vk=; b=jdU27JU/Q5EmWTW8yljYfc5Gpb8IotvXUMD5UEL0yBuYvDeIyCecqFMDZzv3tU4nzX I1cizwqfhTYUSckmv0yCQzZJseVHne2PWVKL0YS+G6ceVDtuhoUU0Yr8U7w+48e5WAEM KTkCcPhnXAY+CNK9HLuSlj9zURZv4HlE6CCHsLc5GJ917GMuO8iVyOmNujrew/f0aQ0r aTrKf2Ffz8pTF9caV1Yxh8feQJkD/my3lopIf7feZj1S7fMcSyslH1xZAyE8cEXIQhev jnsw5Mqai7M8fCyT9ch9JLeiIntOXiNI43Q5Ig0mFePrRcTF/vBsvbmn/UkeinWN5H+H sW8w== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@adacore.com header.s=google header.b=lo6ouJ2b; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id t15-20020a05622a148f00b00417cf21cf2esi1186920qtx.676.2023.10.19.00.59.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:59:24 -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=@adacore.com header.s=google header.b=lo6ouJ2b; arc=pass (i=1); 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=adacore.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5F6D43857347 for ; Thu, 19 Oct 2023 07:59:24 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by sourceware.org (Postfix) with ESMTPS id A9B8E3858D33 for ; Thu, 19 Oct 2023 07:58:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A9B8E3858D33 Authentication-Results: sourceware.org; dmarc=pass (p=none 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 A9B8E3858D33 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::62d ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697702340; cv=none; b=NyfjyCGWnqcfixPFeSt7JOlKoyt0BYP6xSOAguOBEiL4PxMCcbAT5ATUewGF7Si7D4oTSZr22NO0Q29CJ6wRhQ2M21DH4y+qpq7LpRpnpa6OLovASDFlPk0MnkgHxvlNRLxh3FomZc6pPxJxecb6zq+rvbOZ7bjlGkvZXs1rUQc= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1697702340; c=relaxed/simple; bh=jLVtee4HfuoKcpQAekAiKiOjxhOZwbKrBsQNbEi05CY=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=t/+uHS8GML1unCShW2IgHsW8KMdm5VonFZZZaVW7XDaWtGTAMoHu2oCD4yrvTU4RYnxhChxHtwfptFMBr1a1jKYrKcNqoHDpBlOeZ38boD0E+8ed0waDTu0DlJ1n7phtSh8ZW3xR1nmssYjBadpe8LD2eUM/YIa+TaTlAi5m3P8= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c9e95aa02dso4004915ad.0 for ; Thu, 19 Oct 2023 00:58:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=adacore.com; s=google; t=1697702337; x=1698307137; darn=gcc.gnu.org; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=5zMYe+PRBqEExgMRKXKcv0iTQrCnpE2qQyBIKd8Io1M=; b=lo6ouJ2b4rn77yCrRIG1LeT+tpmudc5zm/whhgd6g3CEm33xvf2gF9PCO69FWlYHKQ 73pXuRL/M0aSMawpEiFIQguEjFKsEHXQ4qDrCHUsLXId8gYzZMspwsEFMupPOX6F8qje Vd/lCHH5bmP3//0y8jjovMVRs/WdQW6+81L0lKdvLAtA6QR1TcAhLgeoUsIOizcTGJCL YWj6gD0o+RO2mYpw3cfaZ9piDXAI+ltiof2BsXu/5zySTRTwhdB6WcAhmh6dzt/nAtDA E858FmMo1TOf4ln2qxE3jTDoLCsmR2+YGFHIGz1wxCVEbAmxondqQrMcTPjyfiGiS3A4 d7dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697702337; x=1698307137; h=mime-version:user-agent:message-id:date:organization:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=5zMYe+PRBqEExgMRKXKcv0iTQrCnpE2qQyBIKd8Io1M=; b=coW2tAvyZ8GovzpPEPbrlrE5XEjRD7/QDrtxGsQXHWx23Ta0NjvGCJLoojHoF1Z7Ff pFnxzG6bbtdfzRylHVc38Js4xqhlFhge16rD7YUPBdbo2kyasdNhwl1xCUGan+krPQ4x ogp11W6ZYfsa9ZUKH8L/DbD9w0ZOaLiWw2IrTlNYKhEMPaM/HJputCJX3c5JbA7v9Gli 2uNu/8RvBBHlGC4IXrAMUKGYHCN/G/AGSsT5NYI3rIBkkA+lwATXQ15U9fgDueaDerd5 nGVXziFpIB9yfe6gWFFspDYruxa+nlIqqjfZnu6NGUY+1RztzjZE26TcXaK4KTVlowvM zgNQ== X-Gm-Message-State: AOJu0Yx7wv17H7YBd195SVdE7AxZp+PFl5Jo5WxVFKFbWhd7VS5WPaie 0kKvnnJxPhtUDqaGY3ndetIyF2jBdsbPQUpy2KkOkQ== X-Received: by 2002:a17:902:f54d:b0:1ca:42b:f625 with SMTP id h13-20020a170902f54d00b001ca042bf625mr1990510plf.3.1697702337378; Thu, 19 Oct 2023 00:58:57 -0700 (PDT) Received: from free.home ([2804:7f1:2080:7ba0:18cb:7459:1c6c:8dbf]) by smtp.gmail.com with ESMTPSA id z13-20020a170902ee0d00b001c877f27d1fsm1240008plb.11.2023.10.19.00.58.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Oct 2023 00:58:57 -0700 (PDT) Received: from livre (livre.home [172.31.160.2]) by free.home (8.15.2/8.15.2) with ESMTPS id 39J7wibs1498615 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 19 Oct 2023 04:58:45 -0300 From: Alexandre Oliva To: gcc-patches@gcc.gnu.org Cc: hubicka@ucw.cz Subject: [PATCH] return edge in make_eh_edges Organization: Free thinker, does not speak for AdaCore Date: Thu, 19 Oct 2023 04:58:44 -0300 Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 X-Spam-Status: No, score=-12.3 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, WEIRD_QUOTING 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+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1780169954926258175 X-GMAIL-MSGID: 1780169954926258175 The need to initialize edge probabilities has made make_eh_edges undesirably hard to use. I suppose we don't want make_eh_edges to initialize the probability of the newly-added edge itself, so that the caller takes care of it, but identifying the added edge in need of adjustments is inefficient and cumbersome. Change make_eh_edges so that it returns the added edge. Regstrapped on x86_64-linux-gnu, and (along with various hardening patches) on ppc64el-linux-gnu. Also tested on multiple other targets, on older versions of GCC. The returned value is unused in code already in the compiler. This is a preparatory patch for uses to be introduced along with stack scrubbing and control flow redundancy. Ok to install? for gcc/ChangeLog * tree-eh.cc (make_eh_edges): Return the new edge. * tree-eh.h (make_eh_edges): Likewise. --- gcc/tree-eh.cc | 6 +++--- gcc/tree-eh.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/tree-eh.cc b/gcc/tree-eh.cc index e8ceff36cc6e7..1cb8e08652909 100644 --- a/gcc/tree-eh.cc +++ b/gcc/tree-eh.cc @@ -2274,7 +2274,7 @@ make_eh_dispatch_edges (geh_dispatch *stmt) /* Create the single EH edge from STMT to its nearest landing pad, if there is such a landing pad within the current function. */ -void +edge make_eh_edges (gimple *stmt) { basic_block src, dst; @@ -2283,14 +2283,14 @@ make_eh_edges (gimple *stmt) lp_nr = lookup_stmt_eh_lp (stmt); if (lp_nr <= 0) - return; + return NULL; lp = get_eh_landing_pad_from_number (lp_nr); gcc_assert (lp != NULL); src = gimple_bb (stmt); dst = label_to_block (cfun, lp->post_landing_pad); - make_edge (src, dst, EDGE_EH); + return make_edge (src, dst, EDGE_EH); } /* Do the work in redirecting EDGE_IN to NEW_BB within the EH region tree; diff --git a/gcc/tree-eh.h b/gcc/tree-eh.h index 771be50fe9a1d..1382568b7c919 100644 --- a/gcc/tree-eh.h +++ b/gcc/tree-eh.h @@ -30,7 +30,7 @@ extern bool remove_stmt_from_eh_lp (gimple *); extern int lookup_stmt_eh_lp_fn (struct function *, const gimple *); extern int lookup_stmt_eh_lp (const gimple *); extern bool make_eh_dispatch_edges (geh_dispatch *); -extern void make_eh_edges (gimple *); +extern edge make_eh_edges (gimple *); extern edge redirect_eh_edge (edge, basic_block); extern void redirect_eh_dispatch_edge (geh_dispatch *, edge, basic_block); extern bool operation_could_trap_helper_p (enum tree_code, bool, bool, bool,