fix -Zsanitizer=kcfi on #[naked] functions
And more broadly only codegen `InstanceKind::Item` using the naked function codegen code. Other instance kinds should follow the normal path.
This commit is contained in:
@@ -530,8 +530,12 @@ fn codegen_cgu_content(
|
||||
for (mono_item, item_data) in mono_items {
|
||||
match mono_item {
|
||||
MonoItem::Fn(instance) => {
|
||||
if tcx.codegen_fn_attrs(instance.def_id()).flags.contains(CodegenFnAttrFlags::NAKED)
|
||||
{
|
||||
// Other `InstanceKind`s (e.g. `ReifyShim` generated by indirect calls) should be
|
||||
// codegened like a normal function.
|
||||
let is_item_instance = matches!(instance.def, InstanceKind::Item(_));
|
||||
|
||||
let flags = tcx.codegen_fn_attrs(instance.def_id()).flags;
|
||||
if is_item_instance && flags.contains(CodegenFnAttrFlags::NAKED) {
|
||||
rustc_codegen_ssa::mir::naked_asm::codegen_naked_asm(
|
||||
&mut GlobalAsmContext { tcx, global_asm: &mut cx.global_asm },
|
||||
instance,
|
||||
|
||||
Reference in New Issue
Block a user