about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/middle
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2021-04-06 04:35:26 +0000
committerbors <bors@rust-lang.org>2021-04-06 04:35:26 +0000
commita6e7a5aa5dc842ddb64607040aefb6ec33e22b59 (patch)
tree5e5cecc462513a6cd3798a8b5b030084dca4d0df /compiler/rustc_middle/src/middle
parent0c7d4effd71f826abb9651419c316b9b57b8ac97 (diff)
parent448d07683a6defd567996114793a09c9a8aef5df (diff)
downloadrust-a6e7a5aa5dc842ddb64607040aefb6ec33e22b59.tar.gz
rust-a6e7a5aa5dc842ddb64607040aefb6ec33e22b59.zip
Auto merge of #81234 - repnop:fn-alignment, r=lcnr
Allow specifying alignment for functions

Fixes #75072

This allows the user to specify alignment for functions, which can be useful for low level work where functions need to necessarily be aligned to a specific value.

I believe the error cases not covered in the match are caught earlier based on my testing so I had them just return `None`.
Diffstat (limited to 'compiler/rustc_middle/src/middle')
-rw-r--r--compiler/rustc_middle/src/middle/codegen_fn_attrs.rs4
1 files changed, 4 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
index bfca6a5f574..7024d9a3d21 100644
--- a/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
+++ b/compiler/rustc_middle/src/middle/codegen_fn_attrs.rs
@@ -38,6 +38,9 @@ pub struct CodegenFnAttrs {
     /// be generated against a specific instruction set. Only usable on architectures which allow
     /// switching between multiple instruction sets.
     pub instruction_set: Option<InstructionSetAttr>,
+    /// The `#[repr(align(...))]` attribute. Indicates the value of which the function should be
+    /// aligned to.
+    pub alignment: Option<u32>,
 }
 
 bitflags! {
@@ -103,6 +106,7 @@ impl CodegenFnAttrs {
             link_section: None,
             no_sanitize: SanitizerSet::empty(),
             instruction_set: None,
+            alignment: None,
         }
     }