Skip to content

Commit 75dfd3f

Browse files
committed
Updated arguments and return types
1 parent 86f76be commit 75dfd3f

File tree

3 files changed

+35
-46
lines changed

3 files changed

+35
-46
lines changed

crates/rustc_codegen_spirv/src/lib.rs

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,9 @@ use maybe_pqp_cg_ssa::traits::{
153153
};
154154
use maybe_pqp_cg_ssa::{CodegenResults, CompiledModule, ModuleCodegen, ModuleKind, TargetConfig};
155155
use rspirv::binary::Assemble;
156-
use rustc_ast::expand::allocator::AllocatorKind;
157-
use rustc_ast::expand::autodiff_attrs::AutoDiffItem;
156+
use rustc_ast::expand::allocator::AllocatorMethod;
158157
use rustc_data_structures::fx::FxIndexMap;
159-
use rustc_errors::{DiagCtxtHandle, FatalError};
158+
use rustc_errors::DiagCtxtHandle;
160159
use rustc_metadata::EncodedMetadata;
161160
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
162161
use rustc_middle::mir::mono::{MonoItem, MonoItemData};
@@ -283,6 +282,10 @@ impl CodegenBackend for SpirvCodegenBackend {
283282
);
284283
drop(timer);
285284
}
285+
286+
fn name(&self) -> &'static str {
287+
"SpirvCodegenBackend"
288+
}
286289
}
287290

288291
struct SpirvModuleBuffer(Vec<u32>);
@@ -301,16 +304,16 @@ impl ThinBufferMethods for SpirvModuleBuffer {
301304
fn data(&self) -> &[u8] {
302305
self.as_bytes()
303306
}
304-
fn thin_link_data(&self) -> &[u8] {
305-
&[]
306-
}
307+
// fn thin_link_data(&self) -> &[u8] {
308+
// &[]
309+
// }
307310
}
308311

309312
impl SpirvCodegenBackend {
310313
fn optimize_common(
311314
_cgcx: &CodegenContext<Self>,
312315
module: &mut ModuleCodegen<<Self as WriteBackendMethods>::Module>,
313-
) -> Result<(), FatalError> {
316+
) -> () {
314317
// Apply DCE ("dead code elimination") to modules before ever serializing
315318
// them as `.spv` files (technically, `.rcgu.o` files inside `.rlib`s),
316319
// that will later get linked (potentially many times, esp. if this is
@@ -320,7 +323,7 @@ impl SpirvCodegenBackend {
320323

321324
// FIXME(eddyb) run as many optimization passes as possible, not just DCE.
322325

323-
Ok(())
326+
()
324327
}
325328
}
326329

@@ -341,8 +344,8 @@ impl WriteBackendMethods for SpirvCodegenBackend {
341344
_exported_symbols_for_lto: &[String],
342345
_each_linked_rlib_for_lto: &[PathBuf],
343346
_modules: Vec<FatLtoInput<Self>>,
344-
_diff_fncs: Vec<AutoDiffItem>,
345-
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
347+
// _diff_fncs: Vec<AutoDiffItem>,
348+
) -> ModuleCodegen<Self::Module> {
346349
assert!(
347350
cgcx.lto == rustc_session::config::Lto::Fat,
348351
"`run_and_optimize_fat_lto` (for `WorkItemResult::NeedsFatLto`) should \
@@ -358,7 +361,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
358361
_each_linked_rlib_for_lto: &[PathBuf], // njn: ?
359362
modules: Vec<(String, Self::ThinBuffer)>,
360363
cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>,
361-
) -> Result<(Vec<ThinModule<Self>>, Vec<WorkProduct>), FatalError> {
364+
) -> (Vec<ThinModule<Self>>, Vec<WorkProduct>) {
362365
link::run_thin(cgcx, modules, cached_modules)
363366
}
364367

@@ -375,14 +378,14 @@ impl WriteBackendMethods for SpirvCodegenBackend {
375378
_dcx: DiagCtxtHandle<'_>,
376379
module: &mut ModuleCodegen<Self::Module>,
377380
_config: &ModuleConfig,
378-
) -> Result<(), FatalError> {
381+
) -> () {
379382
Self::optimize_common(cgcx, module)
380383
}
381384

382385
fn optimize_thin(
383386
cgcx: &CodegenContext<Self>,
384387
thin_module: ThinModule<Self>,
385-
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
388+
) -> ModuleCodegen<Self::Module> {
386389
// FIXME(eddyb) the inefficiency of Module -> [u8] -> Module roundtrips
387390
// comes from upstream and it applies to `rustc_codegen_llvm` as well,
388391
// eventually it should be properly addressed (for `ThinLocal` at least).
@@ -395,15 +398,15 @@ impl WriteBackendMethods for SpirvCodegenBackend {
395398
kind: ModuleKind::Regular,
396399
thin_lto_buffer: None,
397400
};
398-
Self::optimize_common(cgcx, &mut module)?;
399-
Ok(module)
401+
Self::optimize_common(cgcx, &mut module);
402+
module
400403
}
401404

402405
fn codegen(
403406
cgcx: &CodegenContext<Self>,
404407
module: ModuleCodegen<Self::Module>,
405408
_config: &ModuleConfig,
406-
) -> Result<CompiledModule, FatalError> {
409+
) -> CompiledModule {
407410
let kind = module.kind;
408411
let (name, module_buffer) = Self::serialize_module(module);
409412

@@ -414,7 +417,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
414417
);
415418
fs::write(&path, module_buffer.as_bytes()).unwrap();
416419

417-
Ok(CompiledModule {
420+
CompiledModule {
418421
name,
419422
kind,
420423
object: Some(path),
@@ -423,13 +426,10 @@ impl WriteBackendMethods for SpirvCodegenBackend {
423426
assembly: None,
424427
llvm_ir: None,
425428
links_from_incr_cache: vec![],
426-
})
429+
}
427430
}
428431

429-
fn prepare_thin(
430-
module: ModuleCodegen<Self::Module>,
431-
_want_summary: bool,
432-
) -> (String, Self::ThinBuffer) {
432+
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
433433
Self::serialize_module(module)
434434
}
435435

@@ -442,13 +442,7 @@ impl WriteBackendMethods for SpirvCodegenBackend {
442442
}
443443

444444
impl ExtraBackendMethods for SpirvCodegenBackend {
445-
fn codegen_allocator(
446-
&self,
447-
_: TyCtxt<'_>,
448-
_: &str,
449-
_: AllocatorKind,
450-
_: AllocatorKind,
451-
) -> Self::Module {
445+
fn codegen_allocator(&self, _: TyCtxt<'_>, _: &str, _: &[AllocatorMethod]) -> Self::Module {
452446
todo!()
453447
}
454448

crates/rustc_codegen_spirv/src/link.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ use crate::{SpirvCodegenBackend, SpirvModuleBuffer, linker};
66
use ar::{Archive, GnuBuilder, Header};
77
use rspirv::binary::Assemble;
88
use rspirv::dr::Module;
9-
use rustc_ast::CRATE_NODE_ID;
109
use rustc_codegen_spirv_types::{CompileResult, ModuleResult};
1110
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared};
1211
use rustc_codegen_ssa::back::write::CodegenContext;
1312
use rustc_codegen_ssa::{CodegenResults, NativeLib};
1413
use rustc_data_structures::fx::FxHashSet;
15-
use rustc_errors::{Diag, FatalError};
14+
use rustc_errors::Diag;
15+
use rustc_hir::attrs::NativeLibKind;
1616
use rustc_metadata::{EncodedMetadata, fs::METADATA_FILENAME};
1717
use rustc_middle::bug;
1818
use rustc_middle::dep_graph::WorkProduct;
@@ -22,7 +22,6 @@ use rustc_session::config::{
2222
CrateType, DebugInfo, Lto, OptLevel, OutFileName, OutputFilenames, OutputType,
2323
};
2424
use rustc_session::output::{check_file_is_writeable, invalid_output_for_target, out_filename};
25-
use rustc_session::utils::NativeLibKind;
2625
use rustc_span::Symbol;
2726
use std::collections::BTreeMap;
2827
use std::ffi::{CString, OsStr};
@@ -494,11 +493,12 @@ fn add_upstream_native_libraries(
494493

495494
// FIXME(eddyb) upstream has code like this already, maybe we can reuse most of it?
496495
// (see `compiler/rustc_codegen_ssa/src/back/link.rs`)
497-
fn relevant_lib(sess: &Session, lib: &NativeLib) -> bool {
498-
match lib.cfg {
499-
Some(ref cfg) => rustc_attr_parsing::cfg_matches(cfg, sess, CRATE_NODE_ID, None),
500-
None => true,
501-
}
496+
fn relevant_lib(_sess: &Session, _lib: &NativeLib) -> bool {
497+
true
498+
// match lib.cfg {
499+
// Some(ref cfg) => rustc_attr_parsing::cfg_matches(cfg, sess, CRATE_NODE_ID, None),
500+
// None => true,
501+
// }
502502
}
503503

504504
fn create_archive(files: &[&Path], metadata: &[u8], out_filename: &Path) {
@@ -634,7 +634,7 @@ pub(crate) fn run_thin(
634634
cgcx: &CodegenContext<SpirvCodegenBackend>,
635635
modules: Vec<(String, SpirvModuleBuffer)>,
636636
cached_modules: Vec<(SerializedModule<SpirvModuleBuffer>, WorkProduct)>,
637-
) -> Result<(Vec<ThinModule<SpirvCodegenBackend>>, Vec<WorkProduct>), FatalError> {
637+
) -> (Vec<ThinModule<SpirvCodegenBackend>>, Vec<WorkProduct>) {
638638
if cgcx.opts.cg.linker_plugin_lto.enabled() {
639639
unreachable!("We should never reach this case if the LTO step is deferred to the linker");
640640
}
@@ -674,5 +674,5 @@ pub(crate) fn run_thin(
674674
});
675675
}
676676

677-
Ok((opt_jobs, vec![]))
677+
(opt_jobs, vec![])
678678
}

crates/rustc_codegen_spirv/src/linker/test.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ use rustc_span::FileName;
77
use std::io::Write;
88
use std::sync::{Arc, Mutex};
99

10-
// `termcolor` is needed because we cannot construct an Emitter after it was added in
11-
// https://github.com/rust-lang/rust/pull/114104. This can be removed when
12-
// https://github.com/rust-lang/rust/pull/115393 lands.
13-
// We need to construct an emitter as yet another workaround,
14-
// see https://github.com/rust-lang/rust/pull/102992.
15-
extern crate termcolor;
1610
use termcolor::{ColorSpec, WriteColor};
1711

1812
// https://github.com/colin-kiegel/rust-pretty-assertions/issues/24
@@ -162,7 +156,7 @@ fn link_with_linker_opts(
162156
rustc_interface::util::rustc_version_str().unwrap_or("unknown"),
163157
Default::default(),
164158
&rustc_driver_impl::USING_INTERNAL_FEATURES,
165-
Default::default(),
159+
// Default::default(),
166160
);
167161

168162
// HACK(eddyb) inject `write_diags` into `sess`, to work around
@@ -193,6 +187,7 @@ fn link_with_linker_opts(
193187
"".into(),
194188
None,
195189
None,
190+
None,
196191
"".into(),
197192
OutputTypes::new(&[]),
198193
),

0 commit comments

Comments
 (0)