@@ -119,14 +119,14 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
119119 tcx. output_filenames ( ( ) ) . split_dwarf_path (
120120 tcx. sess . split_debuginfo ( ) ,
121121 tcx. sess . opts . unstable_opts . split_dwarf_kind ,
122- Some ( mod_name) ,
122+ mod_name,
123123 )
124124 } else {
125125 None
126126 } ;
127127
128128 let output_obj_file =
129- Some ( tcx. output_filenames ( ( ) ) . temp_path ( OutputType :: Object , Some ( mod_name) ) ) ;
129+ Some ( tcx. output_filenames ( ( ) ) . temp_path_for_cgu ( OutputType :: Object , mod_name) ) ;
130130 let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file } ;
131131
132132 target_machine_factory (
@@ -330,8 +330,7 @@ pub(crate) fn save_temp_bitcode(
330330 return ;
331331 }
332332 let ext = format ! ( "{name}.bc" ) ;
333- let cgu = Some ( & module. name [ ..] ) ;
334- let path = cgcx. output_filenames . temp_path_ext ( & ext, cgu) ;
333+ let path = cgcx. output_filenames . temp_path_ext_for_cgu ( & ext, & module. name ) ;
335334 write_bitcode_to_file ( module, & path)
336335}
337336
@@ -697,11 +696,8 @@ pub(crate) unsafe fn optimize(
697696 let llcx = & * module. module_llvm . llcx ;
698697 let _handlers = DiagnosticHandlers :: new ( cgcx, dcx, llcx, module, CodegenDiagnosticsStage :: Opt ) ;
699698
700- let module_name = module. name . clone ( ) ;
701- let module_name = Some ( & module_name[ ..] ) ;
702-
703699 if config. emit_no_opt_bc {
704- let out = cgcx. output_filenames . temp_path_ext ( "no-opt.bc" , module_name ) ;
700+ let out = cgcx. output_filenames . temp_path_ext_for_cgu ( "no-opt.bc" , & module . name ) ;
705701 write_bitcode_to_file ( module, & out)
706702 }
707703
@@ -747,7 +743,7 @@ pub(crate) unsafe fn optimize(
747743 let thin_lto_buffer = unsafe { ThinBuffer :: from_raw_ptr ( thin_lto_buffer) } ;
748744 module. thin_lto_buffer = Some ( thin_lto_buffer. data ( ) . to_vec ( ) ) ;
749745 let bc_summary_out =
750- cgcx. output_filenames . temp_path ( OutputType :: ThinLinkBitcode , module_name ) ;
746+ cgcx. output_filenames . temp_path_for_cgu ( OutputType :: ThinLinkBitcode , & module . name ) ;
751747 if config. emit_thin_lto_summary
752748 && let Some ( thin_link_bitcode_filename) = bc_summary_out. file_name ( )
753749 {
@@ -804,8 +800,6 @@ pub(crate) unsafe fn codegen(
804800 let llmod = module. module_llvm . llmod ( ) ;
805801 let llcx = & * module. module_llvm . llcx ;
806802 let tm = & * module. module_llvm . tm ;
807- let module_name = module. name . clone ( ) ;
808- let module_name = Some ( & module_name[ ..] ) ;
809803 let _handlers =
810804 DiagnosticHandlers :: new ( cgcx, dcx, llcx, & module, CodegenDiagnosticsStage :: Codegen ) ;
811805
@@ -817,8 +811,8 @@ pub(crate) unsafe fn codegen(
817811 // copy it to the .o file, and delete the bitcode if it wasn't
818812 // otherwise requested.
819813
820- let bc_out = cgcx. output_filenames . temp_path ( OutputType :: Bitcode , module_name ) ;
821- let obj_out = cgcx. output_filenames . temp_path ( OutputType :: Object , module_name ) ;
814+ let bc_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Bitcode , & module . name ) ;
815+ let obj_out = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Object , & module . name ) ;
822816
823817 if config. bitcode_needed ( ) {
824818 if config. emit_bc || config. emit_obj == EmitObj :: Bitcode {
@@ -860,7 +854,8 @@ pub(crate) unsafe fn codegen(
860854 if config. emit_ir {
861855 let _timer =
862856 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_ir" , & * module. name ) ;
863- let out = cgcx. output_filenames . temp_path ( OutputType :: LlvmAssembly , module_name) ;
857+ let out =
858+ cgcx. output_filenames . temp_path_for_cgu ( OutputType :: LlvmAssembly , & module. name ) ;
864859 let out_c = path_to_c_string ( & out) ;
865860
866861 extern "C" fn demangle_callback (
@@ -902,7 +897,7 @@ pub(crate) unsafe fn codegen(
902897 if config. emit_asm {
903898 let _timer =
904899 cgcx. prof . generic_activity_with_arg ( "LLVM_module_codegen_emit_asm" , & * module. name ) ;
905- let path = cgcx. output_filenames . temp_path ( OutputType :: Assembly , module_name ) ;
900+ let path = cgcx. output_filenames . temp_path_for_cgu ( OutputType :: Assembly , & module . name ) ;
906901
907902 // We can't use the same module for asm and object code output,
908903 // because that triggers various errors like invalid IR or broken
@@ -932,7 +927,7 @@ pub(crate) unsafe fn codegen(
932927 . prof
933928 . generic_activity_with_arg ( "LLVM_module_codegen_emit_obj" , & * module. name ) ;
934929
935- let dwo_out = cgcx. output_filenames . temp_path_dwo ( module_name ) ;
930+ let dwo_out = cgcx. output_filenames . temp_path_dwo_for_cgu ( & module . name ) ;
936931 let dwo_out = match ( cgcx. split_debuginfo , cgcx. split_dwarf_kind ) {
937932 // Don't change how DWARF is emitted when disabled.
938933 ( SplitDebuginfo :: Off , _) => None ,
0 commit comments