Skip to content

Commit

Permalink
Auto merge of rust-lang#3851 - rust-lang:rustup-2024-08-29, r=RalfJung
Browse files Browse the repository at this point in the history
Automatic Rustup
  • Loading branch information
bors committed Aug 29, 2024
2 parents d1aa077 + 728a273 commit 4645e6a
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 30 deletions.
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d9a2cc4daee38c63b2f69710ed61d40acc32b709
acb4e8b6251f1d8da36f08e7a70fa23fc581839e
46 changes: 41 additions & 5 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,16 +946,48 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
ecx.machine.validation == ValidationMode::Deep
}

#[inline(always)]
fn enforce_abi(_ecx: &MiriInterpCx<'tcx>) -> bool {
true
}

#[inline(always)]
fn ignore_optional_overflow_checks(ecx: &MiriInterpCx<'tcx>) -> bool {
!ecx.tcx.sess.overflow_checks()
}

fn check_fn_target_features(
ecx: &MiriInterpCx<'tcx>,
instance: ty::Instance<'tcx>,
) -> InterpResult<'tcx> {
let attrs = ecx.tcx.codegen_fn_attrs(instance.def_id());
if attrs
.target_features
.iter()
.any(|feature| !ecx.tcx.sess.target_features.contains(&feature.name))
{
let unavailable = attrs
.target_features
.iter()
.filter(|&feature| {
!feature.implied && !ecx.tcx.sess.target_features.contains(&feature.name)
})
.fold(String::new(), |mut s, feature| {
if !s.is_empty() {
s.push_str(", ");
}
s.push_str(feature.name.as_str());
s
});
let msg = format!(
"calling a function that requires unavailable target features: {unavailable}"
);
// On WASM, this is not UB, but instead gets rejected during validation of the module
// (see #84988).
if ecx.tcx.sess.target.is_like_wasm {
throw_machine_stop!(TerminationInfo::Abort(msg));
} else {
throw_ub_format!("{msg}");
}
}
Ok(())
}

#[inline(always)]
fn find_mir_or_eval_fn(
ecx: &mut MiriInterpCx<'tcx>,
Expand Down Expand Up @@ -1060,6 +1092,10 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
ecx.generate_nan(inputs)
}

fn ub_checks(ecx: &InterpCx<'tcx, Self>) -> InterpResult<'tcx, bool> {
Ok(ecx.tcx.sess.ub_checks())
}

fn thread_local_static_pointer(
ecx: &mut MiriInterpCx<'tcx>,
def_id: DefId,
Expand Down
13 changes: 13 additions & 0 deletions tests/fail/function_calls/target_feature_wasm.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//@only-target-wasm: tests WASM-specific behavior
//@compile-flags: -C target-feature=-simd128

fn main() {
// Calling functions with `#[target_feature]` is not unsound on WASM, see #84988.
// But if the compiler actually uses the target feature, it will lead to an error when the module is loaded.
// We emulate this with an "unsupported" error.
assert!(!cfg!(target_feature = "simd128"));
simd128_fn(); //~ERROR: unavailable target features
}

#[target_feature(enable = "simd128")]
fn simd128_fn() {}
13 changes: 13 additions & 0 deletions tests/fail/function_calls/target_feature_wasm.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
error: abnormal termination: calling a function that requires unavailable target features: simd128
--> $DIR/target_feature_wasm.rs:LL:CC
|
LL | simd128_fn();
| ^^^^^^^^^^^^ calling a function that requires unavailable target features: simd128
|
= note: BACKTRACE:
= note: inside `main` at $DIR/target_feature_wasm.rs:LL:CC

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error

2 changes: 1 addition & 1 deletion tests/fail/intrinsics/intrinsic_target_feature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
// Explicitly disable SSE4.1 because it is enabled by default on macOS
//@compile-flags: -C target-feature=-sse4.1

Expand Down
11 changes: 0 additions & 11 deletions tests/pass/function_calls/target_feature_wasm.rs

This file was deleted.

2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-sha.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+sha,+sse2,+ssse3,+sse4.1

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-adx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+adx

#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-aes-vaes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+aes,+vaes,+avx512f

#![feature(avx512_target_feature, stdarch_x86_avx512)]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-avx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+avx

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-avx2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+avx2

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-avx512.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+avx512f,+avx512vl,+avx512bitalg,+avx512vpopcntdq

#![feature(avx512_target_feature)]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-bmi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+bmi1,+bmi2

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-pause-without-sse2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=-sse2

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-pclmulqdq.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+pclmulqdq

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-sse3-ssse3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
// SSSE3 implicitly enables SSE3
//@compile-flags: -C target-feature=+ssse3

Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-sse41.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+sse4.1

#[cfg(target_arch = "x86")]
Expand Down
2 changes: 1 addition & 1 deletion tests/pass/shims/x86/intrinsics-x86-sse42.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//@ignore-target-avr
//@ignore-target-s390x
//@ignore-target-thumbv7em
//@ignore-target-wasm32
//@ignore-target-wasm
//@compile-flags: -C target-feature=+sse4.2

#[cfg(target_arch = "x86")]
Expand Down

0 comments on commit 4645e6a

Please sign in to comment.