Mark naked functions as never inline in codegen_fn_attrs
Use code generation attributes to ensure that naked functions are never inline, replacing separate checks in MIR inliner and LLVM code generation.
This commit is contained in:
parent
c955add18c
commit
b740cdcf43
3 changed files with 7 additions and 11 deletions
|
@ -258,13 +258,12 @@ pub fn from_fn_attrs<'ll, 'tcx>(
|
||||||
OptimizeAttr::Speed => {}
|
OptimizeAttr::Speed => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
let inline = if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
let inline =
|
||||||
InlineAttr::Never
|
if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
|
||||||
} else if codegen_fn_attrs.inline == InlineAttr::None && instance.def.requires_inline(cx.tcx) {
|
InlineAttr::Hint
|
||||||
InlineAttr::Hint
|
} else {
|
||||||
} else {
|
codegen_fn_attrs.inline
|
||||||
codegen_fn_attrs.inline
|
};
|
||||||
};
|
|
||||||
to_add.extend(inline_attr(cx, inline));
|
to_add.extend(inline_attr(cx, inline));
|
||||||
|
|
||||||
// The `uwtable` attribute according to LLVM is:
|
// The `uwtable` attribute according to LLVM is:
|
||||||
|
|
|
@ -2075,6 +2075,7 @@ fn codegen_fn_attrs(tcx: TyCtxt<'_>, did: DefId) -> CodegenFnAttrs {
|
||||||
|
|
||||||
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
||||||
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
|
codegen_fn_attrs.flags |= CodegenFnAttrFlags::NO_COVERAGE;
|
||||||
|
codegen_fn_attrs.inline = InlineAttr::Never;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Weak lang items have the same semantics as "std internal" symbols in the
|
// Weak lang items have the same semantics as "std internal" symbols in the
|
||||||
|
|
|
@ -363,10 +363,6 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
return Err("C variadic");
|
return Err("C variadic");
|
||||||
}
|
}
|
||||||
|
|
||||||
if callee_attrs.flags.contains(CodegenFnAttrFlags::NAKED) {
|
|
||||||
return Err("naked");
|
|
||||||
}
|
|
||||||
|
|
||||||
if callee_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
if callee_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
|
||||||
return Err("cold");
|
return Err("cold");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue