1
Fork 0

add -Zmin-function-alignment

This commit is contained in:
Folkert de Vries 2024-12-18 22:03:07 +01:00
parent a52085d9f6
commit 47573bf61e
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
8 changed files with 145 additions and 3 deletions

View file

@ -132,9 +132,13 @@ fn prefix_and_suffix<'tcx>(
let attrs = tcx.codegen_fn_attrs(instance.def_id());
let link_section = attrs.link_section.map(|symbol| symbol.as_str().to_string());
let align = attrs.alignment.map(|a| a.bytes()).unwrap_or(4);
// See https://sourceware.org/binutils/docs/as/ARM-Directives.html for info on these directives.
// function alignment can be set globally with the `-Zmin-function-alignment=<n>` flag;
// the alignment from a `#[repr(align(<n>))]` is used if it specifies a higher alignment.
// if no alignment is specified, an alignment of 4 bytes is used.
let min_function_alignment = tcx.sess.opts.unstable_opts.min_function_alignment;
let align = Ord::max(min_function_alignment, attrs.alignment).map(|a| a.bytes()).unwrap_or(4);
// In particular, `.arm` can also be written `.code 32` and `.thumb` as `.code 16`.
let (arch_prefix, arch_suffix) = if is_arm {
(