@@ -4,6 +4,7 @@ use std::num::{IntErrorKind, NonZero};
44use std:: path:: PathBuf ;
55use std:: str;
66
7+ use rustc_abi:: Align ;
78use rustc_data_structures:: fx:: FxIndexMap ;
89use rustc_data_structures:: profiling:: TimePassesFormat ;
910use rustc_data_structures:: stable_hasher:: Hash64 ;
@@ -453,6 +454,7 @@ mod desc {
453454 pub ( crate ) const parse_wasm_c_abi: & str = "`legacy` or `spec`" ;
454455 pub ( crate ) const parse_mir_include_spans: & str =
455456 "either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)" ;
457+ pub ( crate ) const parse_align: & str = "a number that is a power of 2 between 1 and 2^29" ;
456458}
457459
458460pub mod parse {
@@ -1521,6 +1523,21 @@ pub mod parse {
15211523
15221524 true
15231525 }
1526+
1527+ pub ( crate ) fn parse_align ( slot : & mut Option < Align > , v : Option < & str > ) -> bool {
1528+ let mut bytes = 0u64 ;
1529+ if !parse_number ( & mut bytes, v) {
1530+ return false ;
1531+ }
1532+
1533+ let Ok ( align) = Align :: from_bytes ( bytes) else {
1534+ return false ;
1535+ } ;
1536+
1537+ * slot = Some ( align) ;
1538+
1539+ true
1540+ }
15241541}
15251542
15261543options ! {
@@ -1876,6 +1893,8 @@ options! {
18761893 "gather metadata statistics (default: no)" ) ,
18771894 metrics_dir: Option <PathBuf > = ( None , parse_opt_pathbuf, [ UNTRACKED ] ,
18781895 "the directory metrics emitted by rustc are dumped into (implicitly enables default set of metrics)" ) ,
1896+ min_function_alignment: Option <Align > = ( None , parse_align, [ TRACKED ] ,
1897+ "align all functions to at least this many bytes. Must be a power of 2" ) ,
18791898 mir_emit_retag: bool = ( false , parse_bool, [ TRACKED ] ,
18801899 "emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
18811900 (default: no)") ,
0 commit comments