@@ -151,10 +151,9 @@ use maybe_pqp_cg_ssa::traits::{
151151} ;
152152use maybe_pqp_cg_ssa:: { CodegenResults , CompiledModule , ModuleCodegen , ModuleKind , TargetConfig } ;
153153use rspirv:: binary:: Assemble ;
154- use rustc_ast:: expand:: allocator:: AllocatorKind ;
155- use rustc_ast:: expand:: autodiff_attrs:: AutoDiffItem ;
154+ use rustc_ast:: expand:: allocator:: AllocatorMethod ;
156155use rustc_data_structures:: fx:: FxIndexMap ;
157- use rustc_errors:: { DiagCtxtHandle , FatalError } ;
156+ use rustc_errors:: DiagCtxtHandle ;
158157use rustc_metadata:: EncodedMetadata ;
159158use rustc_middle:: dep_graph:: { WorkProduct , WorkProductId } ;
160159use rustc_middle:: mir:: mono:: { MonoItem , MonoItemData } ;
@@ -281,6 +280,10 @@ impl CodegenBackend for SpirvCodegenBackend {
281280 ) ;
282281 drop ( timer) ;
283282 }
283+
284+ fn name ( & self ) -> & ' static str {
285+ "SpirvCodegenBackend"
286+ }
284287}
285288
286289struct SpirvModuleBuffer ( Vec < u32 > ) ;
@@ -299,16 +302,13 @@ impl ThinBufferMethods for SpirvModuleBuffer {
299302 fn data ( & self ) -> & [ u8 ] {
300303 self . as_bytes ( )
301304 }
302- fn thin_link_data ( & self ) -> & [ u8 ] {
303- & [ ]
304- }
305305}
306306
307307impl SpirvCodegenBackend {
308308 fn optimize_common (
309309 _cgcx : & CodegenContext < Self > ,
310310 module : & mut ModuleCodegen < <Self as WriteBackendMethods >:: Module > ,
311- ) -> Result < ( ) , FatalError > {
311+ ) {
312312 // Apply DCE ("dead code elimination") to modules before ever serializing
313313 // them as `.spv` files (technically, `.rcgu.o` files inside `.rlib`s),
314314 // that will later get linked (potentially many times, esp. if this is
@@ -317,8 +317,6 @@ impl SpirvCodegenBackend {
317317 linker:: dce:: dce ( & mut module. module_llvm ) ;
318318
319319 // FIXME(eddyb) run as many optimization passes as possible, not just DCE.
320-
321- Ok ( ( ) )
322320 }
323321}
324322
@@ -339,8 +337,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
339337 _exported_symbols_for_lto : & [ String ] ,
340338 _each_linked_rlib_for_lto : & [ PathBuf ] ,
341339 _modules : Vec < FatLtoInput < Self > > ,
342- _diff_fncs : Vec < AutoDiffItem > ,
343- ) -> Result < ModuleCodegen < Self :: Module > , FatalError > {
340+ ) -> ModuleCodegen < Self :: Module > {
344341 assert ! (
345342 cgcx. lto == rustc_session:: config:: Lto :: Fat ,
346343 "`run_and_optimize_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \
@@ -356,7 +353,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
356353 _each_linked_rlib_for_lto : & [ PathBuf ] , // njn: ?
357354 modules : Vec < ( String , Self :: ThinBuffer ) > ,
358355 cached_modules : Vec < ( SerializedModule < Self :: ModuleBuffer > , WorkProduct ) > ,
359- ) -> Result < ( Vec < ThinModule < Self > > , Vec < WorkProduct > ) , FatalError > {
356+ ) -> ( Vec < ThinModule < Self > > , Vec < WorkProduct > ) {
360357 link:: run_thin ( cgcx, modules, cached_modules)
361358 }
362359
@@ -373,14 +370,14 @@ impl WriteBackendMethods for SpirvCodegenBackend {
373370 _dcx : DiagCtxtHandle < ' _ > ,
374371 module : & mut ModuleCodegen < Self :: Module > ,
375372 _config : & ModuleConfig ,
376- ) -> Result < ( ) , FatalError > {
373+ ) {
377374 Self :: optimize_common ( cgcx, module)
378375 }
379376
380377 fn optimize_thin (
381378 cgcx : & CodegenContext < Self > ,
382379 thin_module : ThinModule < Self > ,
383- ) -> Result < ModuleCodegen < Self :: Module > , FatalError > {
380+ ) -> ModuleCodegen < Self :: Module > {
384381 // FIXME(eddyb) the inefficiency of Module -> [u8] -> Module roundtrips
385382 // comes from upstream and it applies to `rustc_codegen_llvm` as well,
386383 // eventually it should be properly addressed (for `ThinLocal` at least).
@@ -393,15 +390,15 @@ impl WriteBackendMethods for SpirvCodegenBackend {
393390 kind : ModuleKind :: Regular ,
394391 thin_lto_buffer : None ,
395392 } ;
396- Self :: optimize_common ( cgcx, & mut module) ? ;
397- Ok ( module)
393+ Self :: optimize_common ( cgcx, & mut module) ;
394+ module
398395 }
399396
400397 fn codegen (
401398 cgcx : & CodegenContext < Self > ,
402399 module : ModuleCodegen < Self :: Module > ,
403400 _config : & ModuleConfig ,
404- ) -> Result < CompiledModule , FatalError > {
401+ ) -> CompiledModule {
405402 let kind = module. kind ;
406403 let ( name, module_buffer) = Self :: serialize_module ( module) ;
407404
@@ -412,7 +409,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
412409 ) ;
413410 fs:: write ( & path, module_buffer. as_bytes ( ) ) . unwrap ( ) ;
414411
415- Ok ( CompiledModule {
412+ CompiledModule {
416413 name,
417414 kind,
418415 object : Some ( path) ,
@@ -421,13 +418,10 @@ impl WriteBackendMethods for SpirvCodegenBackend {
421418 assembly : None ,
422419 llvm_ir : None ,
423420 links_from_incr_cache : vec ! [ ] ,
424- } )
421+ }
425422 }
426423
427- fn prepare_thin (
428- module : ModuleCodegen < Self :: Module > ,
429- _want_summary : bool ,
430- ) -> ( String , Self :: ThinBuffer ) {
424+ fn prepare_thin ( module : ModuleCodegen < Self :: Module > ) -> ( String , Self :: ThinBuffer ) {
431425 Self :: serialize_module ( module)
432426 }
433427
@@ -440,13 +434,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
440434}
441435
442436impl ExtraBackendMethods for SpirvCodegenBackend {
443- fn codegen_allocator (
444- & self ,
445- _: TyCtxt < ' _ > ,
446- _: & str ,
447- _: AllocatorKind ,
448- _: AllocatorKind ,
449- ) -> Self :: Module {
437+ fn codegen_allocator ( & self , _: TyCtxt < ' _ > , _: & str , _: & [ AllocatorMethod ] ) -> Self :: Module {
450438 todo ! ( )
451439 }
452440
0 commit comments