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.
This commit is contained in:
DianQK 2023-07-18 22:15:47 +08:00
parent f0580df0d5
commit cc08749df2
No known key found for this signature in database
GPG key ID: 46BDB1AC96C48912
8 changed files with 68 additions and 1 deletions

View file

@ -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));
}