public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Thomas Schwinge <tschwinge@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/rust/master] Generic functions should not be TREE_PUBLIC Date: Wed, 8 Jun 2022 12:41:46 +0000 (GMT) [thread overview] Message-ID: <20220608124146.96686386CE55@sourceware.org> (raw) https://gcc.gnu.org/g:cf9d65a913640ecb4f839fbe2e7683ee00dc07f3 commit cf9d65a913640ecb4f839fbe2e7683ee00dc07f3 Author: Philip Herron <philip.herron@embecosm.com> Date: Mon May 2 10:53:14 2022 +0100 Generic functions should not be TREE_PUBLIC Generic functions cannot be public since the symbols could overlap in linking other crates reusing the same generic. The other benifit here is that when optimizations are turned on we can eliminate more code since the symbol does not _need_ to be public. Diff: --- gcc/rust/backend/rust-compile-base.cc | 8 +++++--- gcc/rust/backend/rust-compile-base.h | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/gcc/rust/backend/rust-compile-base.cc b/gcc/rust/backend/rust-compile-base.cc index b969b7a6efc..49f31fca233 100644 --- a/gcc/rust/backend/rust-compile-base.cc +++ b/gcc/rust/backend/rust-compile-base.cc @@ -38,14 +38,14 @@ bool inline should_mangle_item (const tree fndecl) void HIRCompileBase::setup_fndecl (tree fndecl, bool is_main_entry_point, - HIR::Visibility &visibility, + bool is_generic_fn, HIR::Visibility &visibility, const HIR::FunctionQualifiers &qualifiers, const AST::AttrVec &attrs) { // if its the main fn or pub visibility mark its as DECL_PUBLIC // please see https://github.com/Rust-GCC/gccrs/pull/137 bool is_pub = visibility.get_vis_type () == HIR::Visibility::VisType::PUBLIC; - if (is_main_entry_point || is_pub) + if (is_main_entry_point || (is_pub && !is_generic_fn)) { TREE_PUBLIC (fndecl) = 1; } @@ -427,7 +427,9 @@ HIRCompileBase::compile_function ( unsigned int flags = 0; tree fndecl = ctx->get_backend ()->function (compiled_fn_type, ir_symbol_name, "" /* asm_name */, flags, locus); - setup_fndecl (fndecl, is_main_fn, visibility, qualifiers, outer_attrs); + + setup_fndecl (fndecl, is_main_fn, fntype->has_subsititions_defined (), + visibility, qualifiers, outer_attrs); setup_abi_options (fndecl, fntype->get_abi ()); // conditionally mangle the function name diff --git a/gcc/rust/backend/rust-compile-base.h b/gcc/rust/backend/rust-compile-base.h index c09c5620e53..f12913ce970 100644 --- a/gcc/rust/backend/rust-compile-base.h +++ b/gcc/rust/backend/rust-compile-base.h @@ -76,7 +76,7 @@ protected: tree expression, Location locus); static void setup_fndecl (tree fndecl, bool is_main_entry_point, - HIR::Visibility &visibility, + bool is_generic_fn, HIR::Visibility &visibility, const HIR::FunctionQualifiers &qualifiers, const AST::AttrVec &attrs);
reply other threads:[~2022-06-08 12:41 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=20220608124146.96686386CE55@sourceware.org \ --to=tschwinge@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).