diff options
Diffstat (limited to 'compiler/rustc_session')
| -rw-r--r-- | compiler/rustc_session/Cargo.toml | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 46 | ||||
| -rw-r--r-- | compiler/rustc_session/src/options.rs | 49 | ||||
| -rw-r--r-- | compiler/rustc_session/src/parse.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_session/src/search_paths.rs | 11 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 3 |
6 files changed, 50 insertions, 63 deletions
diff --git a/compiler/rustc_session/Cargo.toml b/compiler/rustc_session/Cargo.toml index 31892c13438..a087725d34d 100644 --- a/compiler/rustc_session/Cargo.toml +++ b/compiler/rustc_session/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "rustc_session" version = "0.0.0" -edition = "2021" +edition = "2024" [dependencies] # tidy-alphabetical-start diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 85ef69ea2b7..8f0b17b5e88 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -198,33 +198,26 @@ pub enum CoverageLevel { /// The different settings that the `-Z autodiff` flag can have. #[derive(Clone, Copy, PartialEq, Hash, Debug)] pub enum AutoDiff { + /// Enable the autodiff opt pipeline + Enable, + /// Print TypeAnalysis information PrintTA, /// Print ActivityAnalysis Information PrintAA, /// Print Performance Warnings from Enzyme PrintPerf, - /// Combines the three print flags above. - Print, + /// Print intermediate IR generation steps + PrintSteps, /// Print the whole module, before running opts. PrintModBefore, - /// Print the whole module just before we pass it to Enzyme. - /// For Debug purpose, prefer the OPT flag below - PrintModAfterOpts, /// Print the module after Enzyme differentiated everything. - PrintModAfterEnzyme, + PrintModAfter, - /// Enzyme's loose type debug helper (can cause incorrect gradients) + /// Enzyme's loose type debug helper (can cause incorrect gradients!!) + /// Usable in cases where Enzyme errors with `can not deduce type of X`. LooseTypes, - - /// More flags - NoModOptAfter, - /// Tell Enzyme to run LLVM Opts on each function it generated. By default off, - /// since we already optimize the whole module after Enzyme is done. - EnableFncOpt, - NoVecUnroll, - RuntimeActivity, - /// Runs Enzyme specific Inlining + /// Runs Enzyme's aggressive inlining Inline, } @@ -2928,12 +2921,13 @@ pub enum WasiExecModel { /// how the hash should be calculated when adding a new command-line argument. pub(crate) mod dep_tracking { use std::collections::BTreeMap; - use std::hash::{DefaultHasher, Hash}; + use std::hash::Hash; use std::num::NonZero; use std::path::PathBuf; use rustc_abi::Align; use rustc_data_structures::fx::FxIndexMap; + use rustc_data_structures::stable_hasher::StableHasher; use rustc_errors::LanguageIdentifier; use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; @@ -2960,7 +2954,7 @@ pub(crate) mod dep_tracking { pub(crate) trait DepTrackingHash { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ); @@ -2969,7 +2963,7 @@ pub(crate) mod dep_tracking { macro_rules! impl_dep_tracking_hash_via_hash { ($($t:ty),+ $(,)?) => {$( impl DepTrackingHash for $t { - fn hash(&self, hasher: &mut DefaultHasher, _: ErrorOutputType, _for_crate_hash: bool) { + fn hash(&self, hasher: &mut StableHasher, _: ErrorOutputType, _for_crate_hash: bool) { Hash::hash(self, hasher); } } @@ -2979,7 +2973,7 @@ pub(crate) mod dep_tracking { impl<T: DepTrackingHash> DepTrackingHash for Option<T> { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3064,7 +3058,7 @@ pub(crate) mod dep_tracking { { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3083,7 +3077,7 @@ pub(crate) mod dep_tracking { { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3099,7 +3093,7 @@ pub(crate) mod dep_tracking { impl<T: DepTrackingHash> DepTrackingHash for Vec<T> { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3114,7 +3108,7 @@ pub(crate) mod dep_tracking { impl<T: DepTrackingHash, V: DepTrackingHash> DepTrackingHash for FxIndexMap<T, V> { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3129,7 +3123,7 @@ pub(crate) mod dep_tracking { impl DepTrackingHash for OutputTypes { fn hash( &self, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { @@ -3146,7 +3140,7 @@ pub(crate) mod dep_tracking { // This is a stable hash because BTreeMap is a sorted container pub(crate) fn stable_hash( sub_hashes: BTreeMap<&'static str, &dyn DepTrackingHash>, - hasher: &mut DefaultHasher, + hasher: &mut StableHasher, error_format: ErrorOutputType, for_crate_hash: bool, ) { diff --git a/compiler/rustc_session/src/options.rs b/compiler/rustc_session/src/options.rs index 351dad3f3e4..8977365ee73 100644 --- a/compiler/rustc_session/src/options.rs +++ b/compiler/rustc_session/src/options.rs @@ -1,5 +1,4 @@ use std::collections::BTreeMap; -use std::hash::{DefaultHasher, Hasher}; use std::num::{IntErrorKind, NonZero}; use std::path::PathBuf; use std::str; @@ -7,6 +6,7 @@ use std::str; use rustc_abi::Align; use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::profiling::TimePassesFormat; +use rustc_data_structures::stable_hasher::StableHasher; use rustc_errors::{ColorConfig, LanguageIdentifier, TerminalUrl}; use rustc_feature::UnstableFeatures; use rustc_hashes::Hash64; @@ -251,7 +251,7 @@ macro_rules! top_level_options { } impl Options { - pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> u64 { + pub fn dep_tracking_hash(&self, for_crate_hash: bool) -> Hash64 { let mut sub_hashes = BTreeMap::new(); $({ hash_opt!($opt, @@ -260,7 +260,7 @@ macro_rules! top_level_options { for_crate_hash, [$dep_tracking_marker]); })* - let mut hasher = DefaultHasher::new(); + let mut hasher = StableHasher::new(); dep_tracking::stable_hash(sub_hashes, &mut hasher, self.error_format, @@ -545,7 +545,7 @@ macro_rules! options { build_options(early_dcx, matches, target_modifiers, $stat, $prefix, $outputname) } - fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> u64 { + fn dep_tracking_hash(&self, for_crate_hash: bool, error_format: ErrorOutputType) -> Hash64 { let mut sub_hashes = BTreeMap::new(); $({ hash_opt!($opt, @@ -554,7 +554,7 @@ macro_rules! options { for_crate_hash, [$dep_tracking_marker]); })* - let mut hasher = DefaultHasher::new(); + let mut hasher = StableHasher::new(); dep_tracking::stable_hash(sub_hashes, &mut hasher, error_format, @@ -707,7 +707,7 @@ mod desc { pub(crate) const parse_list: &str = "a space-separated list of strings"; pub(crate) const parse_list_with_polarity: &str = "a comma-separated list of strings, with elements beginning with + or -"; - pub(crate) const parse_autodiff: &str = "a comma separated list of settings: `Print`, `PrintTA`, `PrintAA`, `PrintPerf`, `PrintModBefore`, `PrintModAfterOpts`, `PrintModAfterEnzyme`, `LooseTypes`, `NoModOptAfter`, `EnableFncOpt`, `NoVecUnroll`, `Inline`"; + pub(crate) const parse_autodiff: &str = "a comma separated list of settings: `Enable`, `PrintSteps`, `PrintTA`, `PrintAA`, `PrintPerf`, `PrintModBefore`, `PrintModAfter`, `LooseTypes`, `Inline`"; pub(crate) const parse_comma_list: &str = "a comma-separated list of strings"; pub(crate) const parse_opt_comma_list: &str = parse_comma_list; pub(crate) const parse_number: &str = "a number"; @@ -1348,17 +1348,14 @@ pub mod parse { v.sort_unstable(); for &val in v.iter() { let variant = match val { + "Enable" => AutoDiff::Enable, "PrintTA" => AutoDiff::PrintTA, "PrintAA" => AutoDiff::PrintAA, "PrintPerf" => AutoDiff::PrintPerf, - "Print" => AutoDiff::Print, + "PrintSteps" => AutoDiff::PrintSteps, "PrintModBefore" => AutoDiff::PrintModBefore, - "PrintModAfterOpts" => AutoDiff::PrintModAfterOpts, - "PrintModAfterEnzyme" => AutoDiff::PrintModAfterEnzyme, + "PrintModAfter" => AutoDiff::PrintModAfter, "LooseTypes" => AutoDiff::LooseTypes, - "NoModOptAfter" => AutoDiff::NoModOptAfter, - "EnableFncOpt" => AutoDiff::EnableFncOpt, - "NoVecUnroll" => AutoDiff::NoVecUnroll, "Inline" => AutoDiff::Inline, _ => { // FIXME(ZuseZ4): print an error saying which value is not recognized @@ -2081,21 +2078,19 @@ options! { assume_incomplete_release: bool = (false, parse_bool, [TRACKED], "make cfg(version) treat the current version as incomplete (default: no)"), autodiff: Vec<crate::config::AutoDiff> = (Vec::new(), parse_autodiff, [TRACKED], - "a list of optional autodiff flags to enable - Optional extra settings: - `=PrintTA` - `=PrintAA` - `=PrintPerf` - `=Print` - `=PrintModBefore` - `=PrintModAfterOpts` - `=PrintModAfterEnzyme` - `=LooseTypes` - `=NoModOptAfter` - `=EnableFncOpt` - `=NoVecUnroll` - `=Inline` - Multiple options can be combined with commas."), + "a list of autodiff flags to enable + Mandatory setting: + `=Enable` + Optional extra settings: + `=PrintTA` + `=PrintAA` + `=PrintPerf` + `=PrintSteps` + `=PrintModBefore` + `=PrintModAfter` + `=LooseTypes` + `=Inline` + Multiple options can be combined with commas."), #[rustc_lint_opt_deny_field_access("use `Session::binary_dep_depinfo` instead of this field")] binary_dep_depinfo: bool = (false, parse_bool, [TRACKED], "include artifacts (sysroot, crate dependencies) used during compilation in dep-info \ diff --git a/compiler/rustc_session/src/parse.rs b/compiler/rustc_session/src/parse.rs index e0405a71f65..1fe521bd32d 100644 --- a/compiler/rustc_session/src/parse.rs +++ b/compiler/rustc_session/src/parse.rs @@ -329,7 +329,7 @@ impl ParseSess { self.proc_macro_quoted_spans.push(span) } - pub fn proc_macro_quoted_spans(&self) -> impl Iterator<Item = (usize, Span)> + '_ { + pub fn proc_macro_quoted_spans(&self) -> impl Iterator<Item = (usize, Span)> { // This is equivalent to `.iter().copied().enumerate()`, but that isn't possible for // AppendOnlyVec, so we resort to this scheme. self.proc_macro_quoted_spans.iter_enumerated() diff --git a/compiler/rustc_session/src/search_paths.rs b/compiler/rustc_session/src/search_paths.rs index b750d870cb6..00e12b45baf 100644 --- a/compiler/rustc_session/src/search_paths.rs +++ b/compiler/rustc_session/src/search_paths.rs @@ -20,12 +20,11 @@ pub struct FilesIndex(Vec<(Arc<str>, SearchPathFile)>); impl FilesIndex { /// Look up [SearchPathFile] by (prefix, suffix) pair. - pub fn query<'this, 'prefix, 'suffix>( - &'this self, - prefix: &'prefix str, - suffix: &'suffix str, - ) -> Option<impl Iterator<Item = (String, &'this SearchPathFile)> + use<'this, 'prefix, 'suffix>> - { + pub fn query<'s>( + &'s self, + prefix: &str, + suffix: &str, + ) -> Option<impl Iterator<Item = (String, &'s SearchPathFile)>> { let start = self.0.partition_point(|(k, _)| **k < *prefix); if start == self.0.len() { return None; diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index c4d45ee02ee..8e5ff1d3bc4 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1019,8 +1019,7 @@ pub fn build_session( let self_profiler = if let SwitchWithOptPath::Enabled(ref d) = sopts.unstable_opts.self_profile { - let directory = - if let Some(ref directory) = d { directory } else { std::path::Path::new(".") }; + let directory = if let Some(directory) = d { directory } else { std::path::Path::new(".") }; let profiler = SelfProfiler::new( directory, |
