|
2 | 2 |
|
3 | 3 | use rustc_codegen_ssa::traits::*;
|
4 | 4 | use rustc_hir::def_id::DefId;
|
5 |
| -use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; |
| 5 | +use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, PatchableFunctionEntry}; |
6 | 6 | use rustc_middle::ty::{self, TyCtxt};
|
7 | 7 | use rustc_session::config::{FunctionReturn, OptLevel};
|
8 | 8 | use rustc_span::symbol::sym;
|
@@ -56,9 +56,12 @@ fn inline_attr<'ll>(cx: &CodegenCx<'ll, '_>, inline: InlineAttr) -> Option<&'ll
|
56 | 56 | #[inline]
|
57 | 57 | fn patchable_function_entry_attrs<'ll>(
|
58 | 58 | cx: &CodegenCx<'ll, '_>,
|
| 59 | + attr: Option<PatchableFunctionEntry>, |
59 | 60 | ) -> SmallVec<[&'ll Attribute; 2]> {
|
60 | 61 | let mut attrs = SmallVec::new();
|
61 |
| - let patchable_spec = cx.tcx.sess.opts.unstable_opts.patchable_function_entry; |
| 62 | + let patchable_spec = attr.unwrap_or_else(|| { |
| 63 | + PatchableFunctionEntry::from_config(cx.tcx.sess.opts.unstable_opts.patchable_function_entry) |
| 64 | + }); |
62 | 65 | let entry = patchable_spec.entry();
|
63 | 66 | let prefix = patchable_spec.prefix();
|
64 | 67 | if entry > 0 {
|
@@ -446,7 +449,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
446 | 449 | llvm::set_alignment(llfn, align);
|
447 | 450 | }
|
448 | 451 | to_add.extend(sanitize_attrs(cx, codegen_fn_attrs.no_sanitize));
|
449 |
| - to_add.extend(patchable_function_entry_attrs(cx)); |
| 452 | + to_add.extend(patchable_function_entry_attrs(cx, codegen_fn_attrs.patchable_function_entry)); |
450 | 453 |
|
451 | 454 | // Always annotate functions with the target-cpu they are compiled for.
|
452 | 455 | // Without this, ThinLTO won't inline Rust functions into Clang generated
|
|
0 commit comments