@@ -32,6 +32,7 @@ use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken};
32
32
use crate :: debuginfo:: TypeDebugContext ;
33
33
use crate :: global_asm:: { GlobalAsmConfig , GlobalAsmContext } ;
34
34
use crate :: prelude:: * ;
35
+ use crate :: serializable_module:: SerializableModule ;
35
36
use crate :: unwind_module:: UnwindModule ;
36
37
37
38
fn disable_incr_cache ( ) -> bool {
@@ -512,7 +513,7 @@ fn codegen_cgu_content(
512
513
tcx : TyCtxt < ' _ > ,
513
514
module : & mut dyn Module ,
514
515
cgu_name : rustc_span:: Symbol ,
515
- ) -> ( Vec < CodegenedFunction > , String ) {
516
+ ) -> ( Vec < ( SerializableModule , String ) > , String ) {
516
517
let _timer = tcx. prof . generic_activity_with_arg ( "codegen cgu" , cgu_name. as_str ( ) ) ;
517
518
518
519
let cgu = tcx. codegen_unit ( cgu_name) ;
@@ -543,16 +544,41 @@ fn codegen_cgu_content(
543
544
) ;
544
545
continue ;
545
546
}
547
+
548
+ /*let dep_node = mono_item.codegen_dep_node(tcx);
549
+ let ((ser_module, global_asm), _) = tcx.dep_graph.with_task(
550
+ dep_node,
551
+ tcx,
552
+ (cgu.name(), instance),
553
+ |tcx, (cgu_name, instance)| {*/
554
+ let mut ser_module = SerializableModule :: new ( crate :: build_isa ( tcx. sess , false ) ) ;
546
555
let codegened_function = crate :: base:: codegen_fn (
547
556
tcx,
548
557
cgu_name,
549
558
//debug_context.as_mut(),
550
559
//&mut type_dbg,
551
560
Function :: new ( ) ,
552
- module ,
561
+ & mut ser_module ,
553
562
instance,
554
563
) ;
555
- codegened_functions. push ( codegened_function) ;
564
+ let mut cached_context = Context :: new ( ) ;
565
+ let mut global_asm = String :: new ( ) ;
566
+ crate :: base:: compile_fn (
567
+ & tcx. prof ,
568
+ & tcx. output_filenames ( ( ) ) ,
569
+ crate :: pretty_clif:: should_write_ir ( tcx. sess ) ,
570
+ & mut cached_context,
571
+ & mut ser_module,
572
+ //debug_context.as_mut(),
573
+ & mut global_asm,
574
+ codegened_function,
575
+ ) ;
576
+ /*(ser_module, global_asm)
577
+ },
578
+ Some(rustc_middle::dep_graph::hash_result),
579
+ );*/
580
+
581
+ codegened_functions. push ( ( ser_module, global_asm) ) ;
556
582
}
557
583
MonoItem :: Static ( def_id) => {
558
584
let data_id = crate :: constant:: codegen_static ( tcx, module, def_id) ;
@@ -591,27 +617,16 @@ fn module_codegen(
591
617
592
618
let profiler = tcx. prof . clone ( ) ;
593
619
let invocation_temp = tcx. sess . invocation_temp . clone ( ) ;
594
- let output_filenames = tcx. output_filenames ( ( ) ) . clone ( ) ;
595
- let should_write_ir = crate :: pretty_clif:: should_write_ir ( tcx. sess ) ;
596
620
597
621
OngoingModuleCodegen :: Async ( std:: thread:: spawn ( move || {
598
622
profiler. clone ( ) . generic_activity_with_arg ( "compile functions" , & * cgu_name) . run ( || {
599
623
cranelift_codegen:: timing:: set_thread_profiler ( Box :: new ( super :: MeasuremeProfiler (
600
624
profiler. clone ( ) ,
601
625
) ) ) ;
602
626
603
- let mut cached_context = Context :: new ( ) ;
604
- for codegened_func in codegened_functions {
605
- crate :: base:: compile_fn (
606
- & profiler,
607
- & output_filenames,
608
- should_write_ir,
609
- & mut cached_context,
610
- & mut module,
611
- //debug_context.as_mut(),
612
- & mut global_asm,
613
- codegened_func,
614
- ) ;
627
+ for ( codegened_func, asm) in codegened_functions {
628
+ codegened_func. apply_to ( & mut module) ;
629
+ global_asm. push_str ( & asm) ;
615
630
}
616
631
} ) ;
617
632
0 commit comments