From 24f271d7042650b9674085b9f82575dbbbe76b86 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Wed, 4 Sep 2024 07:38:53 +0200 Subject: [PATCH] do not set the attributes quite as often --- compiler/rustc_codegen_llvm/src/abi.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_codegen_llvm/src/abi.rs b/compiler/rustc_codegen_llvm/src/abi.rs index 60d40fd7b8eb1..cc2b3e8e58025 100644 --- a/compiler/rustc_codegen_llvm/src/abi.rs +++ b/compiler/rustc_codegen_llvm/src/abi.rs @@ -663,7 +663,12 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> { } // If the call site has an associated instance, compute extra attributes based on that. - if let Some(instance) = instance { + // However, only do that for calls to imported functions: all the others have these + // attributes applied already to the declaration, so we can save some work by not also + // applying them here (and this really shows in perf). + if let Some(instance) = instance + && bx.tcx.is_foreign_item(instance.def_id()) + { llfn_attrs_from_instance(bx.cx, instance, None, |place, attrs| { attributes::apply_to_callsite(callsite, place, attrs) });