Skip to content

Commit 297313f

Browse files
committed
---
yaml --- r: 69438 b: refs/heads/auto c: 075560a h: refs/heads/master v: v3
1 parent f77d1a3 commit 297313f

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 293ec2c5820e8b5dc4394e2c11ad3d2e9cfb56eb
17+
refs/heads/auto: 075560a9f2f715ac0e599a13d26d1a910be36509
1818
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1919
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c

branches/auto/src/librustc/driver/driver.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -409,12 +409,19 @@ pub fn stop_after_phase_5(sess: Session) -> bool {
409409
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
410410
outdir: &Option<Path>, output: &Option<Path>) {
411411
let outputs = build_output_filenames(input, outdir, output, [], sess);
412-
let crate = phase_1_parse_input(sess, cfg.clone(), input);
413-
if stop_after_phase_1(sess) { return; }
414-
let expanded_crate = phase_2_configure_and_expand(sess, cfg, crate);
415-
let analysis = phase_3_run_analysis_passes(sess, expanded_crate);
416-
if stop_after_phase_3(sess) { return; }
417-
let trans = phase_4_translate_to_llvm(sess, expanded_crate, &analysis, outputs);
412+
// We need nested scopes here, because the intermediate results can keep
413+
// large chunks of memory alive and we want to free them as soon as
414+
// possible to keep the peak memory usage low
415+
let trans = {
416+
let expanded_crate = {
417+
let crate = phase_1_parse_input(sess, cfg.clone(), input);
418+
if stop_after_phase_1(sess) { return; }
419+
phase_2_configure_and_expand(sess, cfg, crate)
420+
};
421+
let analysis = phase_3_run_analysis_passes(sess, expanded_crate);
422+
if stop_after_phase_3(sess) { return; }
423+
phase_4_translate_to_llvm(sess, expanded_crate, &analysis, outputs)
424+
};
418425
phase_5_run_llvm_passes(sess, &trans, outputs);
419426
if stop_after_phase_5(sess) { return; }
420427
phase_6_link_output(sess, &trans, outputs);

0 commit comments

Comments
 (0)