about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src/attributes.rs
diff options
context:
space:
mode:
authorFolkert de Vries <folkert@folkertdev.nl>2024-12-18 22:03:07 +0100
committerFolkert de Vries <folkert@folkertdev.nl>2025-01-10 22:53:54 +0100
commit47573bf61ec0807cee3cf2c5c1ca88bb7d5b89cd (patch)
treebe340fec403359a7cfcc5cb06b61f555e7b0788b /compiler/rustc_codegen_llvm/src/attributes.rs
parenta52085d9f6a6e596b0cbad4502cddf86bc878028 (diff)
downloadrust-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.rs6
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) {