Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to nightly-2023-03-04 #1005

Merged
merged 5 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/rustc_codegen_spirv/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use std::process::{Command, ExitCode};
/// `cargo publish`. We need to figure out a way to do this properly, but let's hardcode it for now :/
//const REQUIRED_RUST_TOOLCHAIN: &str = include_str!("../../rust-toolchain");
const REQUIRED_RUST_TOOLCHAIN: &str = r#"[toolchain]
channel = "nightly-2023-01-21"
channel = "nightly-2023-03-04"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14"#;
# commit_hash = 44cfafe2fafe816395d3acc434663a45d5178c41"#;

fn get_rustc_commit_hash() -> Result<String, Box<dyn Error>> {
let rustc = std::env::var("RUSTC").unwrap_or_else(|_| String::from("rustc"));
Expand Down
18 changes: 10 additions & 8 deletions crates/rustc_codegen_spirv/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,13 @@ pub(crate) fn provide(providers: &mut Providers) {
// We can't capture the old fn_sig and just call that, because fn_sig is a `fn`, not a `Fn`, i.e. it can't
// capture variables. Fortunately, the defaults are exposed (thanks rustdoc), so use that instead.
let result = (rustc_interface::DEFAULT_QUERY_PROVIDERS.fn_sig)(tcx, def_id);
result.map_bound(|mut inner| {
if let SpecAbi::C { .. } = inner.abi {
inner.abi = SpecAbi::Unadjusted;
}
inner
result.map_bound(|outer| {
outer.map_bound(|mut inner| {
if let SpecAbi::C { .. } = inner.abi {
inner.abi = SpecAbi::Unadjusted;
}
inner
})
})
};

Expand Down Expand Up @@ -94,7 +96,7 @@ pub(crate) fn provide(providers: &mut Providers) {

// FIXME(eddyb) remove this by deriving `Clone` for `LayoutS` upstream.
// FIXME(eddyb) the `S` suffix is a naming antipattern, rename upstream.
fn clone_layout<V: Idx>(layout: &LayoutS<V>) -> LayoutS<V> {
fn clone_layout(layout: &LayoutS) -> LayoutS {
let LayoutS {
ref fields,
ref variants,
Expand Down Expand Up @@ -158,7 +160,7 @@ pub(crate) fn provide(providers: &mut Providers) {
};

if hide_niche {
layout = tcx.intern_layout(LayoutS {
layout = tcx.mk_layout(LayoutS {
largest_niche: None,
..clone_layout(layout.0 .0)
});
Expand Down Expand Up @@ -502,7 +504,7 @@ fn trans_scalar<'tcx>(
}
Primitive::F32 => SpirvType::Float(32).def(span, cx),
Primitive::F64 => SpirvType::Float(64).def(span, cx),
Primitive::Pointer => {
Primitive::Pointer(_) => {
let pointee_ty = dig_scalar_pointee(cx, ty, offset);
// Pointers can be recursive. So, record what we're currently translating, and if we're already translating
// the same type, emit an OpTypeForwardPointer and use that ID.
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/builder/builder_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,7 @@ impl<'a, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'tcx> {
OverflowOp::Mul => (self.mul(lhs, rhs), fals),
};
self.zombie(
result.0.def(self),
result.1.def(self),
match oop {
OverflowOp::Add => "checked add is not supported yet",
OverflowOp::Sub => "checked sub is not supported yet",
Expand Down
9 changes: 8 additions & 1 deletion crates/rustc_codegen_spirv/src/builder/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,14 @@ impl<'a, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'tcx> {
let res3 = self.or(res3, res4);
self.or(res1, res3)
}
other => self.fatal(&format!("bswap not implemented for int width {other}")),
other => {
let undef = self.undef(ret_ty);
self.zombie(
undef.def(self),
&format!("bswap not implemented for int width {other}"),
);
undef
}
}
}

Expand Down
16 changes: 8 additions & 8 deletions crates/rustc_codegen_spirv/src/codegen_cx/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
assert_eq!(res.ty, ty);
res
}
Primitive::Pointer => {
Primitive::Pointer(_) => {
if data == 0 {
self.constant_null(ty)
} else {
Expand Down Expand Up @@ -317,14 +317,14 @@ impl<'tcx> ConstMethods<'tcx> for CodegenCx<'tcx> {
// let offset = self.constant_u64(ptr.offset.bytes());
// self.gep(base_addr, once(offset))
};
if layout.primitive() != Primitive::Pointer {
if let Primitive::Pointer(_) = layout.primitive() {
assert_ty_eq!(self, value.ty, ty);
value
} else {
self.tcx
.sess
.fatal("Non-pointer-typed scalar_to_backend Scalar::Ptr not supported");
// unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
oisyn marked this conversation as resolved.
Show resolved Hide resolved
} else {
assert_ty_eq!(self, value.ty, ty);
value
// unsafe { llvm::LLVMConstPtrToInt(llval, llty) }
}
}
}
Expand Down Expand Up @@ -440,7 +440,7 @@ impl<'tcx> CodegenCx<'tcx> {
.fatal(format!("invalid size for float: {other}"));
}
},
SpirvType::Pointer { .. } => Primitive::Pointer,
SpirvType::Pointer { .. } => Primitive::Pointer(AddressSpace::DATA),
unsupported_spirv_type => bug!(
"invalid spirv type internal to create_alloc_const2: {:?}",
unsupported_spirv_type
Expand All @@ -454,7 +454,7 @@ impl<'tcx> CodegenCx<'tcx> {
let value = match alloc.inner().read_scalar(
self,
alloc_range(*offset, size),
primitive.is_ptr(),
matches!(primitive, Primitive::Pointer(_)),
) {
Ok(scalar) => {
self.scalar_to_backend(scalar, self.primitive_to_scalar(primitive), ty)
Expand Down
2 changes: 1 addition & 1 deletion crates/rustc_codegen_spirv/src/codegen_cx/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::bug;
use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs};
use rustc_middle::mir::mono::{Linkage, MonoItem, Visibility};
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf};
use rustc_middle::ty::{self, Instance, ParamEnv, TypeVisitable};
use rustc_middle::ty::{self, Instance, ParamEnv, TypeVisitableExt};
use rustc_span::def_id::DefId;
use rustc_span::Span;
use rustc_target::abi::Align;
Expand Down
5 changes: 5 additions & 0 deletions crates/rustc_codegen_spirv/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ impl ThinBufferMethods for SpirvThinBuffer {
struct SpirvCodegenBackend;

impl CodegenBackend for SpirvCodegenBackend {
fn locale_resource(&self) -> &'static str {
rustc_errors::DEFAULT_LOCALE_RESOURCE
}

fn target_features(&self, sess: &Session, _allow_unstable: bool) -> Vec<Symbol> {
let cmdline = sess.opts.cg.target_feature.split(',');
let cfg = sess.target.options.features.split(',');
Expand Down Expand Up @@ -284,6 +288,7 @@ impl CodegenBackend for SpirvCodegenBackend {
impl WriteBackendMethods for SpirvCodegenBackend {
type Module = Vec<u32>;
type TargetMachine = ();
type TargetMachineError = String;
type ModuleBuffer = SpirvModuleBuffer;
type ThinData = ();
type ThinBuffer = SpirvThinBuffer;
Expand Down
6 changes: 4 additions & 2 deletions crates/rustc_codegen_spirv/src/linker/test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::{link, LinkResult};
use pipe::pipe;
use rspirv::dr::{Loader, Module};
use rustc_errors::registry::Registry;
use rustc_errors::{registry::Registry, TerminalUrl};
use rustc_session::{config::Input, CompilerIO};
use rustc_span::FileName;
use std::io::Read;
Expand Down Expand Up @@ -144,6 +144,7 @@ fn link_with_linker_opts(
None,
Registry::new(&[]),
Default::default(),
Default::default(),
None,
None,
);
Expand All @@ -154,7 +155,7 @@ fn link_with_linker_opts(
let fallback_bundle = {
extern crate rustc_error_messages;
rustc_error_messages::fallback_fluent_bundle(
rustc_errors::DEFAULT_LOCALE_RESOURCES,
Vec::new(),
sess.opts.unstable_opts.translate_directionality_markers,
)
};
Expand All @@ -169,6 +170,7 @@ fn link_with_linker_opts(
None,
false,
false,
TerminalUrl::No,
);

rustc_errors::Handler::with_emitter_and_flags(
Expand Down
8 changes: 4 additions & 4 deletions crates/rustc_codegen_spirv/src/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ pub(crate) fn parse_attrs_for_checking<'a>(
"unknown `rust_gpu` attribute, expected `rust_gpu::spirv`"
.to_string(),
))),
Vec::new(),
Default::default(),
)
} else if let Some(args) = attr.meta_item_list() {
// #[rust_gpu::spirv(...)]
Expand All @@ -445,15 +445,15 @@ pub(crate) fn parse_attrs_for_checking<'a>(
"#[rust_gpu::spirv(..)] attribute must have at least one argument"
.to_string(),
))),
Vec::new(),
Default::default(),
)
}
} else {
// #[...] but not #[rust_gpu ...]
(None, Vec::new())
(None, Default::default())
}
}
AttrKind::DocComment(..) => (None, Vec::new()), // doccomment
AttrKind::DocComment(..) => (None, Default::default()), // doccomment
};

whole_attr_error
Expand Down
4 changes: 2 additions & 2 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[toolchain]
channel = "nightly-2023-01-21"
channel = "nightly-2023-03-04"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
# commit_hash = 5ce39f42bd2c8bca9c570f0560ebe1fce4eddb14
# commit_hash = 44cfafe2fafe816395d3acc434663a45d5178c41

# Whenever changing the nightly channel, update the commit hash above, and make
# sure to change REQUIRED_TOOLCHAIN in crates/rustc_codegen_spirv/src/build.rs also.
2 changes: 1 addition & 1 deletion tests/ui/arch/debug_printf_type_checking.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ error[E0308]: mismatched types
24 | debug_printf!("%f", Vec2::splat(33.3));
| --------------------^^^^^^^^^^^^^^^^^-
| | |
| | expected `f32`, found struct `Vec2`
| | expected `f32`, found `Vec2`
| arguments to this function are incorrect
|
help: the return type of this call is `Vec2` due to the type of the argument passed
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/dis/ptr_copy.normal.stderr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
error: Cannot memcpy dynamically sized data
--> $CORE_SRC/intrinsics.rs:2458:9
--> $CORE_SRC/intrinsics.rs:2460:9
|
2458 | copy(src, dst, count)
2460 | copy(src, dst, count)
| ^^^^^^^^^^^^^^^^^^^^^
|
= note: Stack:
Expand Down