Skip to content

Commit

Permalink
Auto merge of #88748 - bjorn3:try_fix_perf_regression, r=wesleywiser
Browse files Browse the repository at this point in the history
Revert "Remove optimization_fuel_crate from Session"

This reverts commit 5464b2e.

This hopefully fixes the perf regression in #88530 (comment).
  • Loading branch information
bors committed Sep 9, 2021
2 parents c5cbf78 + 1022646 commit 02a57fa
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion compiler/rustc_session/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ pub struct Session {
/// Data about code being compiled, gathered during compilation.
pub code_stats: CodeStats,

/// If `-zfuel=crate=n` is specified, `Some(crate)`.
optimization_fuel_crate: Option<String>,

/// Tracks fuel info if `-zfuel=crate=n` is specified.
optimization_fuel: Lock<OptimizationFuel>,

Expand Down Expand Up @@ -883,7 +886,7 @@ impl Session {
/// This expends fuel if applicable, and records fuel if applicable.
pub fn consider_optimizing<T: Fn() -> String>(&self, crate_name: &str, msg: T) -> bool {
let mut ret = true;
if let Some(c) = self.opts.debugging_opts.fuel.as_ref().map(|i| &i.0) {
if let Some(ref c) = self.optimization_fuel_crate {
if c == crate_name {
assert_eq!(self.threads(), 1);
let mut fuel = self.optimization_fuel.lock();
Expand Down Expand Up @@ -1254,6 +1257,7 @@ pub fn build_session(
let local_crate_source_file =
local_crate_source_file.map(|path| file_path_mapping.map_prefix(path).0);

let optimization_fuel_crate = sopts.debugging_opts.fuel.as_ref().map(|i| i.0.clone());
let optimization_fuel = Lock::new(OptimizationFuel {
remaining: sopts.debugging_opts.fuel.as_ref().map_or(0, |i| i.1),
out_of_fuel: false,
Expand Down Expand Up @@ -1305,6 +1309,7 @@ pub fn build_session(
normalize_projection_ty: AtomicUsize::new(0),
},
code_stats: Default::default(),
optimization_fuel_crate,
optimization_fuel,
print_fuel,
jobserver: jobserver::client(),
Expand Down

0 comments on commit 02a57fa

Please sign in to comment.