Use standard attribute logic for allocator shim

Use llfn_attrs_from_instance() to generate the attributes for the
allocator shim. This ensures that we generate all the usual
attributes (and don't get to find out one-by-one that a certain
attribute is important for a certain target). Additionally this
will enable emitting the allocator-specific attributes (not
included here).

This change is quite awkward because the allocator shim uses
SimpleCx, while llfn_attrs_from_instance uses CodegenCx. I've
switched it to use SimpleCx plus tcx/sess arguments where necessary.
If there's a simpler way to do this, I'd love to know about it...
This commit is contained in:
Nikita Popov
2025-09-19 14:53:16 +02:00
parent caccb4d036
commit d226e7aa93
7 changed files with 126 additions and 114 deletions

View File

@@ -76,7 +76,7 @@ pub(crate) fn declare_raw_fn<'ll, 'tcx>(
attrs.push(llvm::AttributeKind::NoRedZone.create_attr(cx.llcx));
}
attrs.extend(attributes::non_lazy_bind_attr(cx));
attrs.extend(attributes::non_lazy_bind_attr(cx, cx.tcx.sess));
attributes::apply_to_llfn(llfn, Function, &attrs);