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

Subtree sync for rustc_codegen_cranelift #119117

Merged
merged 43 commits into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
abf0832
Replace `option.map(cond) == Some(true)` with `option.is_some_and(cond)`
dtolnay Nov 24, 2023
1988cf4
Merge commit '710c67909d034e1c663174a016ca82b95c2d6c12' into sync_cg_…
bjorn3 Nov 25, 2023
6b82fe2
Merge branch 'sync_from_rust'
bjorn3 Nov 25, 2023
400cd47
Auto merge of #118279 - bjorn3:sync_cg_clif-2023-11-25, r=bjorn3
bors Nov 25, 2023
62dbc19
Add Windows wrappers for ./y
simonbuchan Nov 27, 2023
f5a74dc
Add missing trailing newline in y.cmd
bjorn3 Nov 29, 2023
db91a41
Merge pull request #1432 from simonbuchan/windows-y-wrappers
bjorn3 Nov 29, 2023
0657c1b
Give `Handler::fatal` and `Session::fatal` the same return type.
nnethercote Dec 1, 2023
9d9459a
Adjust tests for newly added ambiguous_wide_pointer_comparisons lint
Urgau Nov 9, 2023
2559532
Sync from rust 1fdfe1234795a289af1088aefa92ef80191cb611
bjorn3 Dec 7, 2023
3e81ade
Rustup to rustc 1.76.0-nightly (1fdfe1234 2023-12-06)
bjorn3 Dec 7, 2023
994d36b
ctfe interpreter: extend provenance so that it can track whether a po…
RalfJung Nov 25, 2023
1095e01
Fix testing of portable-simd
bjorn3 Dec 7, 2023
6353599
Auto merge of #118324 - RalfJung:ctfe-read-only-pointers, r=saethlin
bors Dec 7, 2023
3ff8e7b
Fix rustc test suite
bjorn3 Dec 7, 2023
8ab225d
Add simd_masked_{load,store} platform-intrinsics
farnoy Nov 15, 2023
e637663
remove redundant imports
surechen Nov 10, 2023
fc1b10c
Sync from rust 06e02d5b259c1e88cbf0c74366d9e0a4c7cfd6d9
bjorn3 Dec 10, 2023
b5c0dd6
Auto merge of #117758 - Urgau:lint_pointer_trait_comparisons, r=david…
bors Dec 11, 2023
aa3dc4c
remove a cranelift test that doesn't make sense any more
RalfJung Dec 2, 2023
ace694c
Rustup to rustc 1.76.0-nightly (06e02d5b2 2023-12-09)
bjorn3 Dec 12, 2023
7ec47d1
Fix rustc test suite
bjorn3 Dec 12, 2023
e3d2831
Auto merge of #118534 - RalfJung:extern-type-size-of-val, r=WaffleLapkin
bors Dec 13, 2023
b1cd90a
Sync from rust 3340d49d22b1aba425779767278c40781826c2f5
bjorn3 Dec 13, 2023
45fab3a
Rustup to rustc 1.76.0-nightly (3340d49d2 2023-12-12)
bjorn3 Dec 13, 2023
bb7a126
Sync from rust eeff92ad32c2627876112ccfe812e19d38494087
bjorn3 Dec 14, 2023
b1c925b
Rustup to rustc 1.76.0-nightly (eeff92ad3 2023-12-13)
bjorn3 Dec 14, 2023
89ab75e
update use of feature flags
lcnr Dec 14, 2023
576b921
Rename `Handler` as `DiagCtxt`.
nnethercote Dec 17, 2023
b44315c
Rename `EarlyErrorHandler` as `EarlyDiagCtxt`.
nnethercote Dec 17, 2023
b60e208
Rename `Session::span_diagnostic` as `Session::dcx`.
nnethercote Dec 17, 2023
8b5a5da
Rename many `DiagCtxt` arguments.
nnethercote Dec 17, 2023
eeb3db1
Rename many `DiagCtxt` and `EarlyDiagCtxt` locals.
nnethercote Dec 18, 2023
fdcf56c
Panic for size_of_val and align_of_val of extern type
bjorn3 Dec 18, 2023
697aa0a
Fix test for size_of_val and align_of_val panicking on extern types
bjorn3 Dec 18, 2023
c4567c1
Implement has_ptr_meta without computing type layout
bjorn3 Dec 18, 2023
1ab05b6
fix dynamic size/align computation logic for packed types with dyn tr…
bjorn3 Dec 18, 2023
973dd56
fix computing the offset of an unsized field in a packed struct
bjorn3 Dec 18, 2023
f6c0006
Sync from rust 6a62871320e262661bb1a0ea7f8aec9d3abeddf2
bjorn3 Dec 18, 2023
9d98f79
Rustup to rustc 1.76.0-nightly (6a6287132 2023-12-17)
bjorn3 Dec 18, 2023
4a1466a
Sync from rust 3f28fe133475ec5faf3413b556bf3cfb0d51336c
bjorn3 Dec 19, 2023
3a9bf72
Rustup to rustc 1.76.0-nightly (3f28fe133 2023-12-18)
bjorn3 Dec 19, 2023
d5c38de
Merge commit '3a9bf729322fb5035518f99b9d76a742bf7c124e' into sync_cg_…
bjorn3 Dec 19, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions compiler/rustc_codegen_cranelift/build_system/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ const EXTENDED_SYSROOT_SUITE: &[TestCase] = &[
if runner.is_native {
let mut test_cmd = PORTABLE_SIMD.test(&runner.target_compiler, &runner.dirs);
test_cmd.arg("-q");
// FIXME remove after portable-simd update
test_cmd
.arg("--")
.arg("--skip")
.arg("core_simd::swizzle::simd_swizzle")
.arg("--skip")
.arg("core_simd::vector::Simd<T,N>::lanes");
spawn_and_wait(test_cmd);
}
}),
Expand Down
11 changes: 0 additions & 11 deletions compiler/rustc_codegen_cranelift/example/mini_core_hello_world.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,17 +337,6 @@ fn main() {
static REF2: &u8 = REF1;
assert_eq!(*REF1, *REF2);

extern "C" {
type A;
}

fn main() {
let x: &A = unsafe { &*(1usize as *const A) };

assert_eq!(unsafe { intrinsics::size_of_val(x) }, 0);
assert_eq!(unsafe { intrinsics::min_align_of_val(x) }, 1);
}

#[repr(simd)]
struct V([f64; 2]);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
From a101a43b795431ce617e7782afb451f4853afc00 Mon Sep 17 00:00:00 2001
From: bjorn3 <17426603+bjorn3@users.noreply.github.com>
Date: Thu, 7 Dec 2023 14:51:35 +0000
Subject: [PATCH] Enable the exposed_provenance feature

---
crates/core_simd/tests/pointers.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/crates/core_simd/tests/pointers.rs b/crates/core_simd/tests/pointers.rs
index 0ae8f83..06620d6 100644
--- a/crates/core_simd/tests/pointers.rs
+++ b/crates/core_simd/tests/pointers.rs
@@ -1,4 +1,4 @@
-#![feature(portable_simd, strict_provenance)]
+#![feature(exposed_provenance, portable_simd, strict_provenance)]

use core_simd::simd::{Simd, SimdConstPtr, SimdMutPtr};

--
2.34.1

55 changes: 35 additions & 20 deletions compiler/rustc_codegen_cranelift/patches/stdlib-lock.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,18 @@ dependencies = [

[[package]]
name = "allocator-api2"
version = "0.2.15"
version = "0.2.16"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "56fc6cf8dc8c4158eed8649f9b8b0ea1518eb62b544fe9490d66fa0b349eafe9"
checksum = "0942ffc6dcaadf03badf6e6a2d0228460359d5e34b57ccdc720b7382dfbd5ec5"

[[package]]
name = "cc"
version = "1.0.79"
version = "1.0.83"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f"
checksum = "f1174fb0b6ec23863f8b971027804a42614e347eafb0a95bf0b12cdae21fc4d0"
dependencies = [
"libc",
]

[[package]]
name = "cfg-if"
Expand All @@ -58,9 +61,9 @@ dependencies = [

[[package]]
name = "compiler_builtins"
version = "0.1.103"
version = "0.1.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a3b73c3443a5fd2438d7ba4853c64e4c8efc2404a9e28a9234cc2d5eebc6c242"
checksum = "99c3f9035afc33f4358773239573f7d121099856753e1bbd2a6a5207098fc741"
dependencies = [
"cc",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -124,9 +127,9 @@ dependencies = [

[[package]]
name = "gimli"
version = "0.28.0"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6fb8d784f27acf97159b40fc4db5ecd8aa23b9ad5ef69cdd136d3bc80665f0c0"
checksum = "4271d37baee1b8c7e4b708028c57d816cf9d2434acb33a549475f78c181f6253"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand All @@ -135,9 +138,9 @@ dependencies = [

[[package]]
name = "hashbrown"
version = "0.14.0"
version = "0.14.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2c6201b9ff9fd90a5a3bac2e56a830d0caa509576f0e503818ee82c181b3437a"
checksum = "290f1a1d9242c78d09ce40a5e87e7554ee637af1351968159f4952f028f75604"
dependencies = [
"allocator-api2",
"compiler_builtins",
Expand All @@ -147,9 +150,9 @@ dependencies = [

[[package]]
name = "hermit-abi"
version = "0.3.2"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "443144c8cdadd93ebf52ddb4056d257f5b52c04d3c804e657d19eb73fc33668b"
checksum = "d77f7ec81a6d05a3abb01ab6eb7590f6083d08449fe5a1c8b1e620283546ccb7"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-alloc",
Expand All @@ -167,9 +170,9 @@ dependencies = [

[[package]]
name = "memchr"
version = "2.5.0"
version = "2.6.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d"
checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand All @@ -189,9 +192,9 @@ dependencies = [

[[package]]
name = "object"
version = "0.32.0"
version = "0.32.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "77ac5bbd07aea88c60a577a1ce218075ffd59208b2d7ca97adf9bfc5aeb21ebe"
checksum = "9cf5f9dd3933bd50a9e1f149ec995f39ae2c496d31fd772c1fd45ebc27e902b0"
dependencies = [
"compiler_builtins",
"memchr",
Expand Down Expand Up @@ -241,9 +244,9 @@ dependencies = [

[[package]]
name = "r-efi"
version = "4.2.0"
version = "4.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "575fc2d9b3da54adbdfaddf6eca48fec256d977c8630a1750b8991347d1ac911"
checksum = "0e244f96e03a3067f9e521d3167bd42657594cb8588c8d3a2db01545dc1af2e0"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand Down Expand Up @@ -402,9 +405,9 @@ dependencies = [

[[package]]
name = "unicode-width"
version = "0.1.10"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c0edd1e5b14653f783770bce4a4dabb4a5108a5370a5f5d8cfe8710c361f6c8b"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
Expand All @@ -419,6 +422,18 @@ dependencies = [
"compiler_builtins",
"core",
"libc",
"unwinding",
]

[[package]]
name = "unwinding"
version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37a19a21a537f635c16c7576f22d0f2f7d63353c1337ad4ce0d8001c7952a25b"
dependencies = [
"compiler_builtins",
"gimli",
"rustc-std-workspace-core",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_cranelift/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-11-25"
channel = "nightly-2023-12-19"
components = ["rust-src", "rustc-dev", "llvm-tools"]
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ rm tests/ui/proc-macro/no-mangle-in-proc-macro-issue-111888.rs
# vendor intrinsics
rm tests/ui/sse2.rs # CodegenBackend::target_features not yet implemented
rm tests/ui/simd/array-type.rs # "Index argument for `simd_insert` is not a constant"
rm tests/ui/simd/masked-load-store.rs

# exotic linkages
rm tests/ui/issues/issue-33992.rs # unsupported linkages
Expand Down
16 changes: 8 additions & 8 deletions compiler/rustc_codegen_cranelift/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
fx,
rustc_hir::LangItem::PanicBoundsCheck,
&[index, len, location],
source_info.span,
Some(source_info.span),
);
}
AssertKind::MisalignedPointerDereference { ref required, ref found } => {
Expand All @@ -365,7 +365,7 @@ fn codegen_fn_body(fx: &mut FunctionCx<'_, '_, '_>, start_block: Block) {
fx,
rustc_hir::LangItem::PanicMisalignedPointerDereference,
&[required, found, location],
source_info.span,
Some(source_info.span),
);
}
_ => {
Expand Down Expand Up @@ -945,19 +945,19 @@ pub(crate) fn codegen_panic<'tcx>(
let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap());
let args = [msg_ptr, msg_len, location];

codegen_panic_inner(fx, rustc_hir::LangItem::Panic, &args, source_info.span);
codegen_panic_inner(fx, rustc_hir::LangItem::Panic, &args, Some(source_info.span));
}

pub(crate) fn codegen_panic_nounwind<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
msg_str: &str,
source_info: mir::SourceInfo,
span: Option<Span>,
) {
let msg_ptr = fx.anonymous_str(msg_str);
let msg_len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(msg_str.len()).unwrap());
let args = [msg_ptr, msg_len];

codegen_panic_inner(fx, rustc_hir::LangItem::PanicNounwind, &args, source_info.span);
codegen_panic_inner(fx, rustc_hir::LangItem::PanicNounwind, &args, span);
}

pub(crate) fn codegen_unwind_terminate<'tcx>(
Expand All @@ -967,16 +967,16 @@ pub(crate) fn codegen_unwind_terminate<'tcx>(
) {
let args = [];

codegen_panic_inner(fx, reason.lang_item(), &args, source_info.span);
codegen_panic_inner(fx, reason.lang_item(), &args, Some(source_info.span));
}

fn codegen_panic_inner<'tcx>(
fx: &mut FunctionCx<'_, '_, 'tcx>,
lang_item: rustc_hir::LangItem,
args: &[Value],
span: Span,
span: Option<Span>,
) {
let def_id = fx.tcx.require_lang_item(lang_item, Some(span));
let def_id = fx.tcx.require_lang_item(lang_item, span);

let instance = Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
let symbol_name = fx.tcx.symbol_name(instance).name;
Expand Down
14 changes: 9 additions & 5 deletions compiler/rustc_codegen_cranelift/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,15 @@ fn clif_pair_type_from_ty<'tcx>(

/// Is a pointer to this type a fat ptr?
pub(crate) fn has_ptr_meta<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> bool {
let ptr_ty = Ty::new_ptr(tcx, TypeAndMut { ty, mutbl: rustc_hir::Mutability::Not });
match &tcx.layout_of(ParamEnv::reveal_all().and(ptr_ty)).unwrap().abi {
Abi::Scalar(_) => false,
Abi::ScalarPair(_, _) => true,
abi => unreachable!("Abi of ptr to {:?} is {:?}???", ty, abi),
if ty.is_sized(tcx, ParamEnv::reveal_all()) {
return false;
}

let tail = tcx.struct_tail_erasing_lifetimes(ty, ParamEnv::reveal_all());
match tail.kind() {
ty::Foreign(..) => false,
ty::Str | ty::Slice(..) | ty::Dynamic(..) => true,
_ => bug!("unexpected unsized tail: {:?}", tail),
}
}

Expand Down
20 changes: 9 additions & 11 deletions compiler/rustc_codegen_cranelift/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,13 +487,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
let layout = fx.layout_of(generic_args.type_at(0));
// Note: Can't use is_unsized here as truly unsized types need to take the fixed size
// branch
let size = if let Abi::ScalarPair(_, _) = ptr.layout().abi {
let (_ptr, info) = ptr.load_scalar_pair(fx);
let (size, _align) = crate::unsize::size_and_align_of_dst(fx, layout, info);
size
let meta = if let Abi::ScalarPair(_, _) = ptr.layout().abi {
Some(ptr.load_scalar_pair(fx).1)
} else {
fx.bcx.ins().iconst(fx.pointer_type, layout.size.bytes() as i64)
None
};
let (size, _align) = crate::unsize::size_and_align_of(fx, layout, meta);
ret.write_cvalue(fx, CValue::by_val(size, usize_layout));
}
sym::min_align_of_val => {
Expand All @@ -502,13 +501,12 @@ fn codegen_regular_intrinsic_call<'tcx>(
let layout = fx.layout_of(generic_args.type_at(0));
// Note: Can't use is_unsized here as truly unsized types need to take the fixed size
// branch
let align = if let Abi::ScalarPair(_, _) = ptr.layout().abi {
let (_ptr, info) = ptr.load_scalar_pair(fx);
let (_size, align) = crate::unsize::size_and_align_of_dst(fx, layout, info);
align
let meta = if let Abi::ScalarPair(_, _) = ptr.layout().abi {
Some(ptr.load_scalar_pair(fx).1)
} else {
fx.bcx.ins().iconst(fx.pointer_type, layout.align.abi.bytes() as i64)
None
};
let (_size, align) = crate::unsize::size_and_align_of(fx, layout, meta);
ret.write_cvalue(fx, CValue::by_val(align, usize_layout));
}

Expand Down Expand Up @@ -688,7 +686,7 @@ fn codegen_regular_intrinsic_call<'tcx>(
}
})
});
crate::base::codegen_panic_nounwind(fx, &msg_str, source_info);
crate::base::codegen_panic_nounwind(fx, &msg_str, Some(source_info.span));
return;
}
}
Expand Down