public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Martin Liska <marxin@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-3282] use proper DECL_INITIAL for VTV Date: Thu, 13 Oct 2022 15:47:25 +0000 (GMT) [thread overview] Message-ID: <20221013154725.12D8F3858C55@sourceware.org> (raw) https://gcc.gnu.org/g:fc748d47e95dd612f4a0ef408851df0293173fd8 commit r13-3282-gfc748d47e95dd612f4a0ef408851df0293173fd8 Author: Martin Liska <mliska@suse.cz> Date: Thu Oct 13 15:39:08 2022 +0200 use proper DECL_INITIAL for VTV 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. Diff: --- 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
reply other threads:[~2022-10-13 15:47 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221013154725.12D8F3858C55@sourceware.org \ --to=marxin@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).