From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id DA5513858C55 for ; Thu, 13 Oct 2022 14:25:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA5513858C55 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=suse.cz 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-out1.suse.de (Postfix) with ESMTPS id CD9A2336B7; Thu, 13 Oct 2022 14:25:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1665671152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hqYb6y+BQR/WGcfA5EwKgI0Mqc/1IJN3VsP4ST/wYe8=; b=06Gqa+WCbpAw+vy2RISYch1fnogzCLoU4Vz0i6pBZ8Hb0H7WnuScY45D/Oux9oT49zc7q1 IjdKAoKqVghAiW/aAXVBHDC3f0JZiSprJDQ1XnzkJ8M9IGKp3Skf9BP8zjF2L8SkFbuCjI 6ZPpiqFTp5XBd0xpPgtyoRY5oGG78AQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1665671152; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=hqYb6y+BQR/WGcfA5EwKgI0Mqc/1IJN3VsP4ST/wYe8=; b=RUn8FGYyOfpq2KpnmV3LIlFlsmwhhxIxghvbqzlgSWhyxiWKDy8gqG969A3sbKaFxnJrvq ObY3PZTstsp8lMCw== 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 B52E513AAA; Thu, 13 Oct 2022 14:25:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id wvY8K/AfSGNuWAAAMHmgww (envelope-from ); Thu, 13 Oct 2022 14:25:52 +0000 Message-ID: <79ffd1f4-684e-dead-9d77-f1567acbc1d8@suse.cz> Date: Thu, 13 Oct 2022 16:25:52 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 From: =?UTF-8?Q?Martin_Li=c5=a1ka?= Subject: [PATCH] use proper DECL_INITIAL for VTV To: gcc-patches@gcc.gnu.org Content-Language: en-US Cc: Jason Merrill , Richard Biener Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_SOFTFAIL,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 List-Id: Hi. I am working on the early debug info emission that would benefit from a late use of asm_put_file. This is last blocker where C++ emits early a section directive in assemble_vtv_preinit_initializer. We can use a proper DECL_INITIAL for that. Patch can bootstrap on x86_64-linux-gnu and survives regression tests. with --enable-vtable-verify. Ready to be installed? Thanks, Martin gcc/cp/ChangeLog: * vtable-class-hierarchy.cc (vtv_generate_init_routine): Emit an artificial variable that would be put into .preinit_array section. gcc/ChangeLog: * output.h (assemble_vtv_preinit_initializer): Remove. * varasm.cc (assemble_vtv_preinit_initializer): Remove. --- gcc/cp/vtable-class-hierarchy.cc | 14 ++++++++++++-- gcc/output.h | 4 ---- gcc/varasm.cc | 17 ----------------- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/gcc/cp/vtable-class-hierarchy.cc b/gcc/cp/vtable-class-hierarchy.cc index 79cb5f8de02..cc1df1ebdb2 100644 --- a/gcc/cp/vtable-class-hierarchy.cc +++ b/gcc/cp/vtable-class-hierarchy.cc @@ -1192,8 +1192,18 @@ vtv_generate_init_routine (void) cgraph_node::add_new_function (vtv_fndecl, false); if (flag_vtable_verify == VTV_PREINIT_PRIORITY && !TARGET_PECOFF) - assemble_vtv_preinit_initializer (vtv_fndecl); - + { + tree vtv_var + = build_decl (BUILTINS_LOCATION, VAR_DECL, + get_identifier ("__vtv_preinit"), + build_pointer_type (TREE_TYPE (vtv_fndecl))); + TREE_STATIC (vtv_var) = 1; + DECL_ARTIFICIAL (vtv_var) = 1; + DECL_INITIAL (vtv_var) = build_fold_addr_expr (vtv_fndecl); + set_decl_section_name (vtv_var, ".preinit_array"); + + varpool_node::add (vtv_var); + } } pop_lang_context (); } diff --git a/gcc/output.h b/gcc/output.h index 6dea630913a..6936bdeeb6c 100644 --- a/gcc/output.h +++ b/gcc/output.h @@ -199,10 +199,6 @@ extern void assemble_end_function (tree, const char *); initial value (that will be done by the caller). */ extern void assemble_variable (tree, int, int, int); -/* Put the vtable verification constructor initialization function - into the preinit array. */ -extern void assemble_vtv_preinit_initializer (tree); - /* Assemble everything that is needed for a variable declaration that has no definition in the current translation unit. */ extern void assemble_undefined_decl (tree); diff --git a/gcc/varasm.cc b/gcc/varasm.cc index 423f3f91af8..a11184584a2 100644 --- a/gcc/varasm.cc +++ b/gcc/varasm.cc @@ -2419,23 +2419,6 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, } } - -/* Given a function declaration (FN_DECL), this function assembles the - function into the .preinit_array section. */ - -void -assemble_vtv_preinit_initializer (tree fn_decl) -{ - section *sect; - unsigned flags = SECTION_WRITE; - rtx symbol = XEXP (DECL_RTL (fn_decl), 0); - - flags |= SECTION_NOTYPE; - sect = get_section (".preinit_array", flags, fn_decl); - switch_to_section (sect); - assemble_addr_to_section (symbol, sect); -} - /* Return 1 if type TYPE contains any pointers. */ static int -- 2.37.3