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_llvm/src/attributes.rs | |
| parent | a52085d9f6a6e596b0cbad4502cddf86bc878028 (diff) | |
| download | rust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.tar.gz rust-47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd.zip | |
add `-Zmin-function-alignment`
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/attributes.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/attributes.rs | 6 | 
1 files changed, 5 insertions, 1 deletions
| diff --git a/compiler/rustc_codegen_llvm/src/attributes.rs b/compiler/rustc_codegen_llvm/src/attributes.rs index f8454fd9960..f84cafb0c4f 100644 --- a/compiler/rustc_codegen_llvm/src/attributes.rs +++ b/compiler/rustc_codegen_llvm/src/attributes.rs @@ -472,7 +472,11 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>( let allocated_pointer = AttributeKind::AllocatedPointer.create_attr(cx.llcx); attributes::apply_to_llfn(llfn, AttributePlace::Argument(0), &[allocated_pointer]); } - if let Some(align) = codegen_fn_attrs.alignment { + // 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 let Some(align) = + Ord::max(cx.tcx.sess.opts.unstable_opts.min_function_alignment, codegen_fn_attrs.alignment) + { llvm::set_alignment(llfn, align); } if let Some(backchain) = backchain_attr(cx) { | 
