Skip to content

Commit 0033cbd

Browse files
committed
---
yaml --- r: 143344 b: refs/heads/try2 c: 075560a h: refs/heads/master v: v3
1 parent a0f70bd commit 0033cbd

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
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 293ec2c5820e8b5dc4394e2c11ad3d2e9cfb56eb
8+
refs/heads/try2: 075560a9f2f715ac0e599a13d26d1a910be36509
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/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)