From patchwork Fri Nov 4 14:06:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 15573 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp429686wru; Fri, 4 Nov 2022 07:15:57 -0700 (PDT) X-Google-Smtp-Source: AMsMyM72Qw2F4ecbAneKFnskkmk7m+PX247ItiCBi+QAOBTNywoKs2Ion0FVe6PO/1m9LnsP6a7h X-Received: by 2002:a17:906:9bc2:b0:7ad:975f:b567 with SMTP id de2-20020a1709069bc200b007ad975fb567mr35496159ejc.107.1667571357137; Fri, 04 Nov 2022 07:15:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667571357; cv=none; d=google.com; s=arc-20160816; b=XR+SG/3XQ3SS0FSfCZVRyZpNTd34gDygAtD3bofsPxbPOt7LJQ3z8TgbuK7g8j82/T vHhgWh3MdUni5CmkQd8bS588QyHg5sNQ7Z1ozIKMFZNU/ZTUCQFCvmmobbISfcS7Htty XMMguYCWJ2mBffbt9HlqekHJTz6FK7s2L11AYBpI1AIPfP5MNAs90iRYN6QNpsw3uRwL c7pszWZrkAj3h38IcPIi6df4Fi+uNx+ZmZlC6XuPxwRxfs8q7BkDgWcXDet6omGuNlJc jnI8zdaGNViKDgUZPY7yhDk1i+owKlI9RxcGiq1Nody7u5D5Zf0g+ZM2xWiQg3zsWV5l o4+Q== 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=riix0hUNCw3qg9STtdfZZyvenBo4qI6/mKW4zgK+ZCw=; b=R5+ZxWd5ajsVrZqBQEfg35MclqoUQzx1EkewKvoyHakJtEIr+PUZsb89T+RuAiq1Tr +Kbokc1XozRUWuNMxwZGucTlV9tlfIN164iZBUBP+U+XqAUPZBOhLdEENGRguyrJMRaU 3YdrXdKNQqlqby+itMcrQQfHa6NfEbPr0Ipz88QGHxHPlZNfvBqCIR/mYE0MFarZr5Dx l1vYibRGewVYaFSwTBRrW61c6Dd+e5DqpguqbYDcfdYZO/Prd+cOSs2VqZWStR7JhTzv JyidxMsbpND45Rfq33eBuUhXPTCLpdDSqypnyHzlAUQ6N65UavyNmSw9xcTtq16HgjwZ muqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="yDo+/qqv"; 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 v26-20020aa7d65a000000b004615b657cbcsi4249711edr.190.2022.11.04.07.15.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Nov 2022 07:15:57 -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="yDo+/qqv"; 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 BC85838AA25C for ; Fri, 4 Nov 2022 14:07:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BC85838AA25C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1667570864; bh=riix0hUNCw3qg9STtdfZZyvenBo4qI6/mKW4zgK+ZCw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=yDo+/qqvhB+KQqTOIDEcrXL7NKnh4IFkrZicpRvpQEk3zxCbRzNDQolNjrfGI38E+ vy66xWA3zOy8JM2oBSpqZXlufyJLSVhSsUi48fnn7jd8V7janeSWU12Op9tmuhAkUG x/6x/VZmmeuWLT23cIOGXffutA6Qzm+/WQ++/Pqc= 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.133.124]) by sourceware.org (Postfix) with ESMTPS id 4D5B03955C8C for ; Fri, 4 Nov 2022 14:06:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 4D5B03955C8C Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-78-3lq9l7-qP6WJ1rpj18ygbQ-1; Fri, 04 Nov 2022 10:06:19 -0400 X-MC-Unique: 3lq9l7-qP6WJ1rpj18ygbQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D2691C075A0; Fri, 4 Nov 2022 14:06:19 +0000 (UTC) Received: from localhost (unknown [10.33.37.13]) by smtp.corp.redhat.com (Postfix) with ESMTP id 22F2BC15BA5; Fri, 4 Nov 2022 14:06:19 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed] libstdc++: Simplify lifetime of eh_globals variable [PR107500] Date: Fri, 4 Nov 2022 14:06:18 +0000 Message-Id: <20221104140618.834765-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, 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: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely 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?1748575302913274957?= X-GMAIL-MSGID: =?utf-8?q?1748575302913274957?= Tested powerpc64le-linux. Pushed to trunk. -- >8 -- Since this is a trivial type, we probably don't need to do anything to ensure it's still accessible after other static dtors. libstdc++-v3/ChangeLog: PR libstdc++/107500 * libsupc++/eh_globals.cc (eh_globals): Remove immortalizing wrapper. (__cxxabiv1::__cxa_get_globals_fast): Adjust. (__cxxabiv1::__cxa_get_globals): Adjust. --- libstdc++-v3/libsupc++/eh_globals.cc | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/libstdc++-v3/libsupc++/eh_globals.cc b/libstdc++-v3/libsupc++/eh_globals.cc index 12abfc10521..74e8a454ecc 100644 --- a/libstdc++-v3/libsupc++/eh_globals.cc +++ b/libstdc++-v3/libsupc++/eh_globals.cc @@ -70,18 +70,8 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW namespace { - struct constant_init - { - union { - __cxa_eh_globals obj; - }; - constexpr constant_init() : obj() { } - - ~constant_init() { /* do nothing, union member is not destroyed */ } - }; - // Single-threaded fallback buffer. - __constinit constant_init eh_globals; + __constinit __cxa_eh_globals eh_globals; } #if __GTHREADS @@ -142,7 +132,7 @@ __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW if (init._S_init) g = static_cast<__cxa_eh_globals*>(__gthread_getspecific(init._M_key)); else - g = &eh_globals.obj; + g = &eh_globals; return g; } @@ -167,7 +157,7 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW } } else - g = &eh_globals.obj; + g = &eh_globals; return g; } @@ -175,11 +165,11 @@ __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW extern "C" __cxa_eh_globals* __cxxabiv1::__cxa_get_globals_fast() _GLIBCXX_NOTHROW -{ return &eh_globals.obj; } +{ return &eh_globals; } extern "C" __cxa_eh_globals* __cxxabiv1::__cxa_get_globals() _GLIBCXX_NOTHROW -{ return &eh_globals.obj; } +{ return &eh_globals; } #endif