From patchwork Sun Mar 28 15:51:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Iain Buclaw X-Patchwork-Id: 1459273 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=CvALwToe; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4F7gDW6vTsz9sRK for ; Mon, 29 Mar 2021 02:51:22 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6BB52385480F; Sun, 28 Mar 2021 15:51:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6BB52385480F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1616946679; bh=NuNIRlg89aFwzJ42dWudtRIa8Cvve3pgAPEW9lmB+SQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=CvALwToe2FHAfOZI4ACzBaQkpy1Q5AruzJm5hvr5sawHt/SeY0vl3j72mlOdiDwJG mpMmkiTpAdMOfdDDEksFE5zwGQZxh5ElxoRxXU220KhZjlTfxnMsjvWzMUj3RVO6kN lvQzid5g5Qz5QgoH1WnXdh3b4AmTONqa998ClvPg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [IPv6:2001:67c:2050::465:201]) by sourceware.org (Postfix) with ESMTPS id 99B48385703C for ; Sun, 28 Mar 2021 15:51:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 99B48385703C Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4F7gDJ5GxyzQjmT; Sun, 28 Mar 2021 17:51:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter03.heinlein-hosting.de (spamfilter03.heinlein-hosting.de [80.241.56.117]) (amavisd-new, port 10030) with ESMTP id WRx2EI1iUAeA; Sun, 28 Mar 2021 17:51:08 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [committed] d: Don't generate per-module wrapper for calling DSO constructor/destructor. Date: Sun, 28 Mar 2021 17:51:07 +0200 Message-Id: <20210328155107.2718261-1-ibuclaw@gdcproject.org> MIME-Version: 1.0 X-MBO-SPAM-Probability: * X-Rspamd-Score: 0.48 / 15.00 / 15.00 X-Rspamd-Queue-Id: 6D98216FF X-Rspamd-UID: 9921be X-Spam-Status: No, score=-15.7 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 autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Iain Buclaw via Gcc-patches From: Iain Buclaw Reply-To: Iain Buclaw Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" Hi, This patch removes the per-module wrapper function for calling the DSO constructor and destructor. The static constructor/destructor list only ever has one function to call in it, so mark the gdc.dso_ctor and gdc.dso_dtor functions as static ctor/dtor directly instead. Bootstrapped and regression tested on x86_64-linux-gnu/-m32/-mx32, and committed to mainline. Regards, Iain. --- gcc/d/ChangeLog: * config-lang.in (gtfiles): Remove modules.cc. * modules.cc (struct module_info): Remove GTY marker. (static_ctor_list): Remove variable. (static_dtor_list): Remove variable. (register_moduleinfo): Directly set DECL_STATIC_CONSTRUCTOR on dso_ctor, and DECL_STATIC_DESTRUCTOR on dso_dtor. (d_finish_compilation): Remove static ctor/dtor handling. gcc/testsuite/ChangeLog: * gdc.dg/gdc270a.d: Removed. * gdc.dg/gdc270b.d: Removed. --- gcc/d/config-lang.in | 2 +- gcc/d/modules.cc | 36 +++++----------------------------- gcc/testsuite/gdc.dg/gdc270a.d | 11 ----------- gcc/testsuite/gdc.dg/gdc270b.d | 7 ------- 4 files changed, 6 insertions(+), 50 deletions(-) delete mode 100644 gcc/testsuite/gdc.dg/gdc270a.d delete mode 100644 gcc/testsuite/gdc.dg/gdc270b.d diff --git a/gcc/d/config-lang.in b/gcc/d/config-lang.in index 66714acf8d1..0568b8da1de 100644 --- a/gcc/d/config-lang.in +++ b/gcc/d/config-lang.in @@ -45,7 +45,7 @@ case "${noconfigdirs}" in ;; esac -gtfiles="\$(srcdir)/d/d-tree.h \$(srcdir)/d/d-builtins.cc \$(srcdir)/d/d-lang.cc \$(srcdir)/d/modules.cc \$(srcdir)/d/typeinfo.cc" +gtfiles="\$(srcdir)/d/d-tree.h \$(srcdir)/d/d-builtins.cc \$(srcdir)/d/d-lang.cc \$(srcdir)/d/typeinfo.cc" # Do not build by default. build_by_default="no" diff --git a/gcc/d/modules.cc b/gcc/d/modules.cc index f51277e61ed..af69815deb9 100644 --- a/gcc/d/modules.cc +++ b/gcc/d/modules.cc @@ -75,7 +75,7 @@ static tree stop_minfo_node; /* Record information about module initialization, termination, unit testing, and thread local storage in the compilation. */ -struct GTY(()) module_info +struct module_info { vec *ctors; vec *dtors; @@ -121,11 +121,6 @@ static module_info *current_testing_module; static Module *current_module_decl; -/* Static constructors and destructors (not D `static this'). */ - -static GTY(()) vec *static_ctor_list; -static GTY(()) vec *static_dtor_list; - /* Returns an internal function identified by IDENT. This is used by both module initialization and dso handlers. */ @@ -460,10 +455,12 @@ register_moduleinfo (Module *decl, tree minfo) /* Declare dso_ctor() and dso_dtor(). */ tree dso_ctor = build_dso_cdtor_fn (true); - vec_safe_push (static_ctor_list, dso_ctor); + DECL_STATIC_CONSTRUCTOR (dso_ctor) = 1; + decl_init_priority_insert (dso_ctor, DEFAULT_INIT_PRIORITY); tree dso_dtor = build_dso_cdtor_fn (false); - vec_safe_push (static_dtor_list, dso_dtor); + DECL_STATIC_DESTRUCTOR (dso_dtor) = 1; + decl_fini_priority_insert (dso_dtor, DEFAULT_INIT_PRIORITY); first_module = false; } @@ -908,27 +905,4 @@ d_finish_compilation (tree *vec, int len) tree decl = vec[i]; wrapup_global_declarations (&decl, 1); } - - /* If the target does not directly support static constructors, - static_ctor_list contains a list of all static constructors defined - so far. This routine will create a function to call all of those - and is picked up by collect2. */ - if (static_ctor_list) - { - tree decl = build_funcs_gates_fn (get_file_function_name ("I"), - static_ctor_list, NULL); - DECL_STATIC_CONSTRUCTOR (decl) = 1; - decl_init_priority_insert (decl, DEFAULT_INIT_PRIORITY); - } - - if (static_dtor_list) - { - tree decl = build_funcs_gates_fn (get_file_function_name ("D"), - static_dtor_list, NULL); - DECL_STATIC_DESTRUCTOR (decl) = 1; - decl_fini_priority_insert (decl, DEFAULT_INIT_PRIORITY); - } } - - -#include "gt-d-modules.h" diff --git a/gcc/testsuite/gdc.dg/gdc270a.d b/gcc/testsuite/gdc.dg/gdc270a.d deleted file mode 100644 index 4df6f02f753..00000000000 --- a/gcc/testsuite/gdc.dg/gdc270a.d +++ /dev/null @@ -1,11 +0,0 @@ -// https://bugzilla.gdcproject.org/show_bug.cgi?id=270 -// { dg-do compile } - -module gdc270; - -void foo() -{ -} - -/* { dg-final { scan-assembler "_GLOBAL__D_6gdc270" } } */ -/* { dg-final { scan-assembler "_GLOBAL__I_6gdc270" } } */ diff --git a/gcc/testsuite/gdc.dg/gdc270b.d b/gcc/testsuite/gdc.dg/gdc270b.d deleted file mode 100644 index 5a544c58693..00000000000 --- a/gcc/testsuite/gdc.dg/gdc270b.d +++ /dev/null @@ -1,7 +0,0 @@ -// https://bugzilla.gdcproject.org/show_bug.cgi?id=270 -// { dg-do compile } - -module gdc270; - -/* { dg-final { scan-assembler "_GLOBAL__D_6gdc270" } } */ -/* { dg-final { scan-assembler "_GLOBAL__I_6gdc270" } } */