Remove LLVM attribute removal
This was necessary before, because `declare_raw_fn` would always apply the default optimization attributes to every declared function, and then `attributes::from_fn_attrs` would have to remove the default attributes in the case of, e.g. `#[optimize(speed)]` in a `-Os` build. However, every relevant callsite of `declare_raw_fn` (i.e. where we actually generate code for the function, and not e.g. a call to an intrinsic, where optimization attributes don't [?] matter) calls `from_fn_attrs`, so we can simply remove the attribute setting from `declare_raw_fn`, and rely on `from_fn_attrs` to apply the correct attributes all at once.
This commit is contained in:
parent
b07d59f794
commit
dce14cfacc
5 changed files with 13 additions and 87 deletions
|
@ -41,21 +41,15 @@ fn declare_raw_fn<'ll>(
|
|||
llvm::SetFunctionCallConv(llfn, callconv);
|
||||
llvm::SetUnnamedAddress(llfn, unnamed);
|
||||
|
||||
let mut attrs_to_remove = SmallVec::<[_; 4]>::new();
|
||||
let mut attrs_to_add = SmallVec::<[_; 4]>::new();
|
||||
let mut attrs = SmallVec::<[_; 4]>::new();
|
||||
|
||||
if cx.tcx.sess.opts.cg.no_redzone.unwrap_or(cx.tcx.sess.target.disable_redzone) {
|
||||
attrs_to_add.push(llvm::AttributeKind::NoRedZone.create_attr(cx.llcx));
|
||||
attrs.push(llvm::AttributeKind::NoRedZone.create_attr(cx.llcx));
|
||||
}
|
||||
|
||||
let (to_remove, to_add) = attributes::default_optimisation_attrs(cx);
|
||||
attrs_to_remove.extend(to_remove);
|
||||
attrs_to_add.extend(to_add);
|
||||
attrs.extend(attributes::non_lazy_bind_attr(cx));
|
||||
|
||||
attrs_to_add.extend(attributes::non_lazy_bind_attr(cx));
|
||||
|
||||
attributes::remove_from_llfn(llfn, Function, &attrs_to_remove);
|
||||
attributes::apply_to_llfn(llfn, Function, &attrs_to_add);
|
||||
attributes::apply_to_llfn(llfn, Function, &attrs);
|
||||
|
||||
llfn
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue