From patchwork Thu Jun 1 03:12:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Merrill X-Patchwork-Id: 101677 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp18246vqr; Wed, 31 May 2023 20:14:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5AFQu0qip4ws0ZFU9GXiuW2fYG3LPub2dgdk9gMm3dd4ozxQYqMlbx1nkJzJsSiiD7r6MT X-Received: by 2002:a17:907:25c2:b0:973:8cb7:4d81 with SMTP id ae2-20020a17090725c200b009738cb74d81mr7999736ejc.49.1685589243042; Wed, 31 May 2023 20:14:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685589243; cv=none; d=google.com; s=arc-20160816; b=u4XkwEDdZdqaABXx4V+BoPpyUevfF6zARkgy1OVbtKi22FvpiHRjUFkYa1cERf4ML0 6aR03jxIDCqgAeKGhtcNJJoagRzbFpnGeHF7Ah5bemoSV9i9ancRsvyllsLvB6SiTCnJ M0F9M/R0oBssX9Dr9g925KAwaX1WyY/JJ6glJT4MmuLFlt2z0TrvEEzot2tO2f2oMHNg oJWdxg2Nao3BAyjHZ2K1z7FWNkLkkNSZuKJLK5PgsXz1vHu1JsBQOiij/YTzvsZuO6+O 2tJnKQQSfcBP01WevjX7gbKKGt8+Kpw/A6xtCVWcg9hlyhPnGOsRVdX3kLGds36WlEEi zyGA== 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 :content-transfer-encoding:mime-version:message-id:date:subject:to :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=1zBCTFQ8vpTkWO1C0yNrC+hco87linpZwRlPAeDNHm0=; b=dJmv402GFfGDMkkwNKC2LXbpJtZto/sNKtEvpqjiWQcZlgNCliDdNhEpNAh9E8z0UK +BN7P9jfJS0vlwSuGr1UaKn4ryxNEV0RuX7FxWKhCCY26n6gMYnUucMWZgcsT4eiPAIR SYxuKwmb+KtxFqqj1cs7kh06IriC0H2ALVSaXsjBv7t2y3m90PEc4d54051+VixdJu8k eeP8z2IbR6aZy1OJLBGFsSoI5OP/JK+gq+A9PTZBeWAuMLhc3IIqswIyy0yfs4YghI1k rSh+QrVlhoYMvelnolt5Dj+9fTO+wEcXL55q5N0x7mUi2xjuvAhdKnkspTR+2dVudc3I Fb/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=tgjSxAIz; 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 (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id j10-20020a170906474a00b0096f69a2f31bsi2026119ejs.1036.2023.05.31.20.14.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 20:14:03 -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=tgjSxAIz; 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 0B73C3857031 for ; Thu, 1 Jun 2023 03:13:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B73C3857031 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1685589230; bh=1zBCTFQ8vpTkWO1C0yNrC+hco87linpZwRlPAeDNHm0=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=tgjSxAIz9S/QPREuyxkYJc5I5Vq455mpUtRr0FzxBk9CuzvD9RdcohExRi7Ck8nFY DIMpDX3zNJkIGUi/aSjIk42HeyNrEGrQpH8x50PNne3ODPKdClyg3rSZptDyqyXHOO 9WPejDYVpDjBlr4OsjagjdY8LJJvvoWGJZzQYFAE= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 1D7A43858D20 for ; Thu, 1 Jun 2023 03:13:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 1D7A43858D20 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-7-ifPBwQjbPWGFUw_7x4D06w-1; Wed, 31 May 2023 23:12:59 -0400 X-MC-Unique: ifPBwQjbPWGFUw_7x4D06w-1 Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-626201ad337so7880346d6.3 for ; Wed, 31 May 2023 20:12:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685589178; x=1688181178; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1zBCTFQ8vpTkWO1C0yNrC+hco87linpZwRlPAeDNHm0=; b=X1smYxrvSBPJtPiJGye8MTlYJH4HpcfMYaaPx1XM4lThrZvP2vuq/CshHN4IoyPrnw LlZeBGSa+nQdf1QQYGQve9EzZLzpvar6r8y3EdZQY3BcVrGbk97lNL5V2z3Q2+C0IcuG 9xFNF6EIuvBTa0pEwPCkb2as2KiHWMQk8ZuiBzA5H3Cy0zzoKbta/tiD6UIlvDZzgF6h Ad2pZte2L/9QsurL+Pn+uM2iNed41LYc/0okJUUZtLL5pVtcryMUSTZuwInvwh7pDOCO nkPvjDiFN5aMOhYsxqf2XzizkAkRKsnsfPepw+Fh3KxTSKxK0znsMedqdlpAC88KsfQo scXw== X-Gm-Message-State: AC+VfDxSIRIUHOVr0OJ3l6y0tvm8kI1Ipo9oBJZxD157ysc9fz8UX/74 m/Bxulke87EWvLZV82BASgN/H5yMFkRg0JGeKJ85ZTvLFcTJHouBMIPaQu0X2aOnpGboiRi9BOQ P2iXxqXkyM/2koaeA80F0/CNuUsuyjsXaWk8rnR8EzL3heapAsm7j66MbkbswZLDXgs+PXdhfGg == X-Received: by 2002:ad4:5be3:0:b0:5f1:683e:9bd6 with SMTP id k3-20020ad45be3000000b005f1683e9bd6mr9200932qvc.9.1685589178676; Wed, 31 May 2023 20:12:58 -0700 (PDT) X-Received: by 2002:ad4:5be3:0:b0:5f1:683e:9bd6 with SMTP id k3-20020ad45be3000000b005f1683e9bd6mr9200914qvc.9.1685589178322; Wed, 31 May 2023 20:12:58 -0700 (PDT) Received: from jason.com (130-44-146-16.s12558.c3-0.arl-cbr1.sbo-arl.ma.cable.rcncustomer.com. [130.44.146.16]) by smtp.gmail.com with ESMTPSA id mn6-20020a0562145ec600b005ef442226bbsm6793419qvb.8.2023.05.31.20.12.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 May 2023 20:12:57 -0700 (PDT) To: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: [PATCH] libstdc++: optimize EH phase 2 Date: Wed, 31 May 2023 23:12:55 -0400 Message-Id: <20230601031255.1268906-1-jason@redhat.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_NUMSUBJECT, 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jason Merrill via Gcc-patches From: Jason Merrill Reply-To: Jason Merrill 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?1767468426369459975?= X-GMAIL-MSGID: =?utf-8?q?1767468426369459975?= Tested x86_64-pc-linux-gnu, OK for trunk? -- 8< -- In the ABI's two-phase EH model, first we walk the stack looking for a handler, then we walk the stack running cleanups until we reach that handler. In the cleanup phase, we shouldn't redundantly check the handlers along the way, e.g. when walking through g(): void f() { throw 42; } void g() { try { f(); } catch (void *) { } } int main() { try { g(); } catch (int) { } } libstdc++-v3/ChangeLog: * libsupc++/eh_personality.cc (PERSONALITY_FUNCTION): Don't check handlers in the cleanup phase. --- libstdc++-v3/libsupc++/eh_personality.cc | 4 ++++ 1 file changed, 4 insertions(+) base-commit: 68816ba245afc6d0e1482bde2d15b35b925b4195 diff --git a/libstdc++-v3/libsupc++/eh_personality.cc b/libstdc++-v3/libsupc++/eh_personality.cc index 12391e563d6..cc6bc048892 100644 --- a/libstdc++-v3/libsupc++/eh_personality.cc +++ b/libstdc++-v3/libsupc++/eh_personality.cc @@ -592,6 +592,10 @@ PERSONALITY_FUNCTION (int version, // Zero filter values are cleanups. saw_cleanup = true; } + else if (actions == _UA_CLEANUP_PHASE) + // We checked the handlers in the search phase; if one of them + // matched, actions would also have _UA_HANDLER_FRAME set. + ; else if (ar_filter > 0) { // Positive filter values are handlers.