diff options
| author | Matthew Maurer <matthew.r.maurer@gmail.com> | 2023-12-12 13:37:04 -0800 |
|---|---|---|
| committer | Florian Schmiderer <florian.schmiderer@posteo.net> | 2024-06-25 18:23:41 +0200 |
| commit | 9b0ae75ecc485d668232c9c85f0090fb85668312 (patch) | |
| tree | 2ad4a6f802fb5eef10f7d15d6fe948a7499b72f8 /compiler/rustc_codegen_llvm/src | |
| parent | ac7595fdb1ee2aafecdd99cd8a3e56192639ada6 (diff) | |
| download | rust-9b0ae75ecc485d668232c9c85f0090fb85668312.tar.gz rust-9b0ae75ecc485d668232c9c85f0090fb85668312.zip | |
Support `#[patchable_function_entries]`
See [RFC](https://github.com/maurer/rust-rfcs/blob/patchable-function-entry/text/0000-patchable-function-entry.md) (yet to be numbered) TODO before submission: * Needs an RFC * Improve error reporting for malformed attributes
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 7cf789ab5d7..cd82894af18 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -2,7 +2,7 @@ use rustc_codegen_ssa::traits::*; use rustc_hir::def_id::DefId; -use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; +use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry}; use rustc_middle::ty::{self, TyCtxt}; use rustc_session::config::{FunctionReturn, OptLevel}; use rustc_span::symbol::sym; @@ -56,9 +56,12 @@ fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll #[inline] fn patchable_function_entry_attrs<'ll>( cx: &CodegenCx<'ll, '_>, + attr: Option<PatchableFunctionEntry>, ) -> SmallVec<[&'ll Attribute; 2]> { let mut attrs = SmallVec::new(); - let patchable_spec = cx.tcx.sess.opts.unstable_opts.patchable_function_entry; + let patchable_spec = attr.unwrap_or_else(|| { + PatchableFunctionEntry::from_config(cx.tcx.sess.opts.unstable_opts.patchable_function_entry) + }); let entry = patchable_spec.entry(); let prefix = patchable_spec.prefix(); if entry > 0 { @@ -446,7 +449,7 @@ pub fn from_fn_attrs<'ll, 'tcx>( llvm::set_alignment(llfn, align); } to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize)); - to_add.extend(patchable_function_entry_attrs(cx)); + to_add.extend(patchable_function_entry_attrs(cx, codegen_fn_attrs.patchable_function_entry)); // Always annotate functions with the target-cpu they are compiled for. // Without this, ThinLTO won't inline Rust functions into Clang generated |
