@@ -32,6 +32,7 @@ use crate::concurrency_limiter::{ConcurrencyLimiter, ConcurrencyLimiterToken};
3232use crate :: debuginfo:: TypeDebugContext ;
3333use crate :: global_asm:: { GlobalAsmConfig , GlobalAsmContext } ;
3434use crate :: prelude:: * ;
35+ use crate :: serializable_module:: SerializableModule ;
3536use crate :: unwind_module:: UnwindModule ;
3637
3738fn disable_incr_cache ( ) -> bool {
@@ -512,7 +513,7 @@ fn codegen_cgu_content(
512513 tcx : TyCtxt < ' _ > ,
513514 module : & mut dyn Module ,
514515 cgu_name : rustc_span:: Symbol ,
515- ) -> ( Vec < CodegenedFunction > , String ) {
516+ ) -> ( Vec < ( SerializableModule , String ) > , String ) {
516517 let _timer = tcx. prof . generic_activity_with_arg ( "codegen cgu" , cgu_name. as_str ( ) ) ;
517518
518519 let cgu = tcx. codegen_unit ( cgu_name) ;
@@ -543,16 +544,41 @@ fn codegen_cgu_content(
543544 ) ;
544545 continue ;
545546 }
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 ) ) ;
546555 let codegened_function = crate :: base:: codegen_fn (
547556 tcx,
548557 cgu_name,
549558 //debug_context.as_mut(),
550559 //&mut type_dbg,
551560 Function :: new ( ) ,
552- module ,
561+ & mut ser_module ,
553562 instance,
554563 ) ;
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) ) ;
556582 }
557583 MonoItem :: Static ( def_id) => {
558584 let data_id = crate :: constant:: codegen_static ( tcx, module, def_id) ;
@@ -591,27 +617,16 @@ fn module_codegen(
591617
592618 let profiler = tcx. prof . clone ( ) ;
593619 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 ) ;
596620
597621 OngoingModuleCodegen :: Async ( std:: thread:: spawn ( move || {
598622 profiler. clone ( ) . generic_activity_with_arg ( "compile functions" , & * cgu_name) . run ( || {
599623 cranelift_codegen:: timing:: set_thread_profiler ( Box :: new ( super :: MeasuremeProfiler (
600624 profiler. clone ( ) ,
601625 ) ) ) ;
602626
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) ;
615630 }
616631 } ) ;
617632
0 commit comments