@@ -4,6 +4,7 @@ use std::num::{IntErrorKind, NonZero};
4
4
use std:: path:: PathBuf ;
5
5
use std:: str;
6
6
7
+ use rustc_abi:: Align ;
7
8
use rustc_data_structures:: fx:: FxIndexMap ;
8
9
use rustc_data_structures:: profiling:: TimePassesFormat ;
9
10
use rustc_data_structures:: stable_hasher:: Hash64 ;
@@ -455,6 +456,7 @@ mod desc {
455
456
pub ( crate ) const parse_wasm_c_abi: & str = "`legacy` or `spec`" ;
456
457
pub ( crate ) const parse_mir_include_spans: & str =
457
458
"either a boolean (`yes`, `no`, `on`, `off`, etc), or `nll` (default: `nll`)" ;
459
+ pub ( crate ) const parse_align: & str = "a number that is a power of 2 between 1 and 2^29" ;
458
460
}
459
461
460
462
pub mod parse {
@@ -1533,6 +1535,21 @@ pub mod parse {
1533
1535
1534
1536
true
1535
1537
}
1538
+
1539
+ pub ( crate ) fn parse_align ( slot : & mut Option < Align > , v : Option < & str > ) -> bool {
1540
+ let mut bytes = 0u64 ;
1541
+ if !parse_number ( & mut bytes, v) {
1542
+ return false ;
1543
+ }
1544
+
1545
+ let Ok ( align) = Align :: from_bytes ( bytes) else {
1546
+ return false ;
1547
+ } ;
1548
+
1549
+ * slot = Some ( align) ;
1550
+
1551
+ true
1552
+ }
1536
1553
}
1537
1554
1538
1555
options ! {
@@ -1888,6 +1905,8 @@ options! {
1888
1905
"gather metadata statistics (default: no)" ) ,
1889
1906
metrics_dir: Option <PathBuf > = ( None , parse_opt_pathbuf, [ UNTRACKED ] ,
1890
1907
"the directory metrics emitted by rustc are dumped into (implicitly enables default set of metrics)" ) ,
1908
+ min_function_alignment: Option <Align > = ( None , parse_align, [ TRACKED ] ,
1909
+ "align all functions to at least this many bytes. Must be a power of 2" ) ,
1891
1910
mir_emit_retag: bool = ( false , parse_bool, [ TRACKED ] ,
1892
1911
"emit Retagging MIR statements, interpreted e.g., by miri; implies -Zmir-opt-level=0 \
1893
1912
(default: no)") ,
0 commit comments