From cc08749df2613c17c8c2e9d8224a24a24c126423 Mon Sep 17 00:00:00 2001 From: DianQK Date: Tue, 18 Jul 2023 22:15:47 +0800 Subject: Add the `no-builtins` attribute to functions when `no_builtins` is applied at the crate level. When `no_builtins` is applied at the crate level, we should add the `no-builtins` attribute to each function to ensure it takes effect in LTO. --- compiler/rustc_codegen_llvm/src/attributes.rs | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'compiler/rustc_codegen_llvm/src') diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index 39275272e42..4c69b9503a2 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -335,6 +335,10 @@ pub fn from_fn_attrs<'ll, 'tcx>( to_add.extend(probestack_attr(cx)); to_add.extend(stackprotector_attr(cx)); + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::NO_BUILTINS) { + to_add.push(llvm::CreateAttrString(cx.llcx, "no-builtins")); + } + if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) { to_add.push(AttributeKind::Cold.create_attr(cx.llcx)); } -- cgit 1.4.1-3-g733a5