diff options
| author | Folkert de Vries <folkert@folkertdev.nl> | 2024-12-18 22:03:07 +0100 |
|---|---|---|
| committer | Folkert de Vries <folkert@folkertdev.nl> | 2025-01-10 22:53:54 +0100 |
| commit | 47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd (patch) | |
| tree | be340fec403359a7cfcc5cb06b61f555e7b0788b /compiler/rustc_codegen_ssa/src | |
| parent | a52085d9f6a6e596b0cbad4502cddf86bc878028 (diff) | |
| download | rust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.tar.gz rust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.zip | |
add `-Zmin-function-alignment`
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/naked_asm.rs | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs index cac3cc587cb..8df270abc81 100644 --- a/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs +++ b/compiler/rustc_codegen_ssa/src/mir/naked_asm.rs @@ -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 { ( |
