10
10
11
11
#![ cfg_attr( not( feature="llvm" ) , allow( dead_code) ) ]
12
12
13
+ use rustc:: dep_graph:: DepGraph ;
13
14
use rustc:: hir:: { self , map as hir_map} ;
14
15
use rustc:: hir:: lowering:: lower_crate;
15
16
use rustc:: ich:: Fingerprint ;
@@ -115,7 +116,7 @@ pub fn compile_input(sess: &Session,
115
116
// We need nested scopes here, because the intermediate results can keep
116
117
// large chunks of memory alive and we want to free them as soon as
117
118
// possible to keep the peak memory usage low
118
- let ( outputs, trans) : ( OutputFilenames , OngoingCrateTranslation ) = {
119
+ let ( outputs, trans, dep_graph ) : ( OutputFilenames , OngoingCrateTranslation , DepGraph ) = {
119
120
let krate = match phase_1_parse_input ( control, sess, input) {
120
121
Ok ( krate) => krate,
121
122
Err ( mut parse_error) => {
@@ -144,7 +145,13 @@ pub fn compile_input(sess: &Session,
144
145
:: rustc_trans_utils:: link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
145
146
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
146
147
phase_2_configure_and_expand (
147
- sess, & cstore, krate, registry, & crate_name, addl_plugins, control. make_glob_map ,
148
+ sess,
149
+ & cstore,
150
+ krate,
151
+ registry,
152
+ & crate_name,
153
+ addl_plugins,
154
+ control. make_glob_map ,
148
155
|expanded_crate| {
149
156
let mut state = CompileState :: state_after_expand (
150
157
input, sess, outdir, output, & cstore, expanded_crate, & crate_name,
@@ -251,7 +258,7 @@ pub fn compile_input(sess: &Session,
251
258
}
252
259
}
253
260
254
- Ok ( ( outputs, trans) )
261
+ Ok ( ( outputs, trans, tcx . dep_graph . clone ( ) ) )
255
262
} ) ??
256
263
} ;
257
264
@@ -266,7 +273,7 @@ pub fn compile_input(sess: &Session,
266
273
sess. code_stats . borrow ( ) . print_type_sizes ( ) ;
267
274
}
268
275
269
- let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, trans) ;
276
+ let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, & dep_graph , trans) ;
270
277
271
278
controller_entry_point ! ( after_llvm,
272
279
sess,
@@ -624,7 +631,15 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
624
631
* sess. features . borrow_mut ( ) = features;
625
632
626
633
* sess. crate_types . borrow_mut ( ) = collect_crate_types ( sess, & krate. attrs ) ;
627
- * sess. crate_disambiguator . borrow_mut ( ) = Symbol :: intern ( & compute_crate_disambiguator ( sess) ) ;
634
+
635
+ let disambiguator = Symbol :: intern ( & compute_crate_disambiguator ( sess) ) ;
636
+ * sess. crate_disambiguator . borrow_mut ( ) = Some ( disambiguator) ;
637
+ rustc_incremental:: prepare_session_directory (
638
+ sess,
639
+ & crate_name,
640
+ & disambiguator. as_str ( ) ,
641
+ ) ;
642
+ let dep_graph = DepGraph :: new ( sess. opts . build_dep_graph ( ) ) ;
628
643
629
644
time ( time_passes, "recursion limit" , || {
630
645
middle:: recursion_limit:: update_limits ( sess, & krate) ;
@@ -694,7 +709,7 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
694
709
// item, much like we do for macro expansion. In other words, the hash reflects not just
695
710
// its contents but the results of name resolution on those contents. Hopefully we'll push
696
711
// this back at some point.
697
- let _ignore = sess . dep_graph . in_ignore ( ) ;
712
+ let _ignore = dep_graph. in_ignore ( ) ;
698
713
let mut crate_loader = CrateLoader :: new ( sess, & cstore, crate_name) ;
699
714
let resolver_arenas = Resolver :: arenas ( ) ;
700
715
let mut resolver = Resolver :: new ( sess,
@@ -847,13 +862,13 @@ pub fn phase_2_configure_and_expand<F>(sess: &Session,
847
862
848
863
// Lower ast -> hir.
849
864
let hir_forest = time ( time_passes, "lowering ast -> hir" , || {
850
- let hir_crate = lower_crate ( sess, cstore, & krate, & mut resolver) ;
865
+ let hir_crate = lower_crate ( sess, cstore, & dep_graph , & krate, & mut resolver) ;
851
866
852
867
if sess. opts . debugging_opts . hir_stats {
853
868
hir_stats:: print_hir_stats ( & hir_crate) ;
854
869
}
855
870
856
- hir_map:: Forest :: new ( hir_crate, & sess . dep_graph )
871
+ hir_map:: Forest :: new ( hir_crate, & dep_graph)
857
872
} ) ;
858
873
859
874
time ( time_passes,
@@ -1134,17 +1149,18 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1134
1149
/// as a side effect.
1135
1150
#[ cfg( feature="llvm" ) ]
1136
1151
pub fn phase_5_run_llvm_passes ( sess : & Session ,
1152
+ dep_graph : & DepGraph ,
1137
1153
trans : write:: OngoingCrateTranslation )
1138
1154
-> ( CompileResult , trans:: CrateTranslation ) {
1139
- let trans = trans. join ( sess) ;
1155
+ let trans = trans. join ( sess, dep_graph ) ;
1140
1156
1141
1157
if sess. opts . debugging_opts . incremental_info {
1142
1158
write:: dump_incremental_data ( & trans) ;
1143
1159
}
1144
1160
1145
1161
time ( sess. time_passes ( ) ,
1146
1162
"serialize work products" ,
1147
- move || rustc_incremental:: save_work_products ( sess) ) ;
1163
+ move || rustc_incremental:: save_work_products ( sess, dep_graph ) ) ;
1148
1164
1149
1165
( sess. compile_status ( ) , trans)
1150
1166
}
0 commit comments