Add allocator attrs#4556
Open
nsvke wants to merge 2 commits into
Open
Conversation
19ef3a5 to
4db115d
Compare
Member
|
You could have |
4db115d to
b27c318
Compare
This patch introduces the `rustc_std_internal_symbol` attribute. This attribute is required by the Rust standard library to prevent name mangling for internal runtime symbols. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (should_mangle_item): Bypass mangling for rustc_std_internal_symbol. (HIRCompileBase::setup_fndecl): Dispatch the new attribute. (HIRCompileBase::handle_rustc_std_internal_symbol_attribute_on_fndecl): New function. * backend/rust-compile-base.h: (handle_rustc_std_internal_symbol_attribute_on_fndecl): New declaration. * util/rust-attribute-values.h (Attributes): Add RUSTC_STD_INTERNAL_SYMBOL constexpr. * util/rust-attributes.cc (__definitions): Register rustc_std_internal_symbol in the BuiltinAttributes list. * checks/errors/rust-builtin-attribute-checker.cc (rustc_std_internal_symbol): New function. (attribute_checking_handlers): Add rustc_std_internal_symbol function. gcc/testsuite/ChangeLog: * rust/compile/rustc_std_internal_symbol1.rs: New test. * rust/compile/rustc_std_internal_symbol2.rs: New test. Signed-off-by: Enes Cevik <enes@nsvke.com>
b27c318 to
d205919
Compare
This patch introduces the `rustc_allocator` and `rustc_allocator_nounwind` attributes. These attributes instruct the GCC backend to apply `malloc` and `nothrow`. gcc/rust/ChangeLog: * backend/rust-compile-base.cc (HIRCompileBase::setup_fndecl): Dispatch the new attributes. (HIRCompileBase::handle_rustc_allocator_on_fndecl): New function. (HIRCompileBase::handle_rustc_allocator_nounwind_on_fndecl): New function. * backend/rust-compile-base.h (handle_rustc_allocator_on_fndecl): New declaration. (handle_rustc_allocator_nounwind_on_fndecl): Likewise. * util/rust-attribute-values.h (Attributes): Add RUSTC_ALLOCATOR and RUSTC_ALLOCATOR_NOUNWIND constexprs. * util/rust-attributes.cc (__definitions): Register rustc_allocator and rustc_allocator_nounwind in the BuiltinAttributes list. * checks/errors/rust-builtin-attribute-checker.cc (rustc_allocator): New function. (rustc_allocator_nounwind): New function. (attribute_checking_handlers): Add rustc_allocator and rustc_allocator_nounwind functions. gcc/testsuite/ChangeLog: * rust/compile/attr-allocator1.rs: New test. * rust/compile/attr-allocator2.rs: New test. * rust/compile/attr-allocator3.rs: New test. Signed-off-by: Enes Cevik <enes@nsvke.com>
d205919 to
fc8cddc
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces three new compiler attributes required for
alloccrate integration and memory allocation support.rustc_std_internal_symbol: Prevents name mangling for internal runtime symbols.rustc_allocatorandrustc_allocator_nounwind: Instruct the GCC backend to applymallocandnothrow.