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

Rollup of 16 pull requests #84975

Closed
wants to merge 45 commits into from
Closed
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
1f32d40
BufWriter: apply #[inline] / #[inline(never)] optimizations
tgnottingham Dec 11, 2020
b43e8e2
BufWriter: avoid using expensive Vec methods
tgnottingham Dec 11, 2020
5fd9372
BufWriter: optimize for write sizes less than buffer size
tgnottingham Dec 13, 2020
72aecbf
BufWriter: handle possibility of overflow
tgnottingham Dec 15, 2020
85bc88d
BufWriter: use #[cold] and less aggressive #[inline] hints
tgnottingham Jan 5, 2021
0f29dc4
BufWriter: simplify buffer draining
tgnottingham Apr 13, 2021
01e7018
BufWriter: improve safety comment
tgnottingham Apr 14, 2021
33cc3f5
Stablize {HashMap,BTreeMap}::into_{keys,values}
Folyd Apr 18, 2021
52fa9da
Rework `wasm::thread` to `thread_atomics`
CDirkx Apr 28, 2021
fab8410
Move `wasm` atomics code to `wasm/atomics`
CDirkx Apr 28, 2021
45bc193
Reuse `unsupported::args` on `wasm`
CDirkx Apr 28, 2021
cf79c06
Fix missing import in `unsupported::args`
CDirkx Apr 28, 2021
8a2e67e
Simplify chdir implementation and minimize unsafe block
joshtriplett Apr 29, 2021
4a63e1e
Allow using `core::` in intra-doc links within core itself
jyn514 Apr 30, 2021
367c1db
:arrow_up: rust-analyzer
lnicola May 3, 2021
6eb4735
Unify rustc and rustdoc parsing of `cfg()`
jyn514 Apr 22, 2021
6b64202
Handle incorrect placement of parentheses in trait bounds more gracef…
estebank May 4, 2021
0b94338
CTFE engine: rename copy → copy_intrinsic, move to intrinsics.rs
RalfJung May 4, 2021
196899a
Update compiler-builtins to 0.1.42 to get fix for outlined atomics
joshtriplett Apr 30, 2021
4bd5505
Only compute Obligation `cache_key` once in `register_obligation_at`
estebank May 4, 2021
42405b4
Fix typo in `MaybeUninit::array_assume_init` safety comment
sdroege May 5, 2021
5b34bf4
Revert PR 83866
pietroalbini May 5, 2021
b6f3dbb
Bump map_into_keys_values stable version to 1.54.0.
m-ou-se May 5, 2021
3584c1d
Disallows `#![feature(no_coverage)]` on stable and beta
richkadel May 3, 2021
4617b03
E0583: Include secondary path in error message
fee1-dead May 5, 2021
568d9c5
compiletest: Add --target-panic, needs-unwind
tmandry Apr 29, 2021
e1a8ecf
Add needs-unwind to tests
tmandry Apr 29, 2021
1993e1a
Support multi target-rustcflags for -Zpanic-abort-tests
tmandry Apr 30, 2021
947ad58
Fix up/ignore failing ui tests on fuchsia
tmandry Apr 30, 2021
b02d15d
Rollup merge of #79930 - tgnottingham:bufwriter_performance, r=m-ou-se
Dylan-DPC May 6, 2021
81dfbfb
Rollup merge of #84328 - Folyd:stablize_map_into_keys_values, r=m-ou-se
Dylan-DPC May 6, 2021
e1873b2
Rollup merge of #84442 - jyn514:doc-cfg, r=petrochenkov
Dylan-DPC May 6, 2021
d2532c1
Rollup merge of #84655 - CDirkx:wasm, r=m-ou-se
Dylan-DPC May 6, 2021
2c98926
Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahc
Dylan-DPC May 6, 2021
f74ad9e
Rollup merge of #84734 - tmandry:compiletest-needs-unwind, r=Mark-Sim…
Dylan-DPC May 6, 2021
f5ed444
Rollup merge of #84755 - jyn514:core-links, r=kennytm
Dylan-DPC May 6, 2021
3a09e05
Rollup merge of #84764 - joshtriplett:update-compiler-builtins, r=Ama…
Dylan-DPC May 6, 2021
8ebb164
Rollup merge of #84851 - lnicola:rust-analyzer-2021-05-03, r=jonas-sc…
Dylan-DPC May 6, 2021
c6556ea
Rollup merge of #84871 - richkadel:no-coverage-unstable-only, r=nagisa
Dylan-DPC May 6, 2021
4956b12
Rollup merge of #84896 - estebank:issue-84772, r=jackh726
Dylan-DPC May 6, 2021
372dfe4
Rollup merge of #84905 - RalfJung:copy, r=oli-obk
Dylan-DPC May 6, 2021
796b745
Rollup merge of #84923 - estebank:as_cache_key-once, r=petrochenkov
Dylan-DPC May 6, 2021
b39024d
Rollup merge of #84945 - fee1-dead:E0583-better-message, r=petrochenkov
Dylan-DPC May 6, 2021
0c94c4b
Rollup merge of #84949 - sdroege:maybe-unint-typo, r=m-ou-se
Dylan-DPC May 6, 2021
ab65989
Rollup merge of #84950 - pietroalbini:revert-3478f83c0, r=Mark-Simula…
Dylan-DPC May 6, 2021
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
34 changes: 33 additions & 1 deletion compiler/rustc_mir/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -323,7 +323,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
self.write_scalar(result, dest)?;
}
sym::copy => {
self.copy(&args[0], &args[1], &args[2], /*nonoverlapping*/ false)?;
self.copy_intrinsic(&args[0], &args[1], &args[2], /*nonoverlapping*/ false)?;
}
sym::offset => {
let ptr = self.read_scalar(&args[0])?.check_init()?;
@@ -530,4 +530,36 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
)?;
Ok(offset_ptr)
}

/// Copy `count*size_of::<T>()` many bytes from `*src` to `*dst`.
pub(crate) fn copy_intrinsic(
&mut self,
src: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
dst: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
count: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
nonoverlapping: bool,
) -> InterpResult<'tcx> {
let count = self.read_scalar(&count)?.to_machine_usize(self)?;
let layout = self.layout_of(src.layout.ty.builtin_deref(true).unwrap().ty)?;
let (size, align) = (layout.size, layout.align.abi);
let size = size.checked_mul(count, self).ok_or_else(|| {
err_ub_format!(
"overflow computing total size of `{}`",
if nonoverlapping { "copy_nonoverlapping" } else { "copy" }
)
})?;

// Make sure we check both pointers for an access of the total size and aligment,
// *even if* the total size is 0.
let src =
self.memory.check_ptr_access(self.read_scalar(&src)?.check_init()?, size, align)?;

let dst =
self.memory.check_ptr_access(self.read_scalar(&dst)?.check_init()?, size, align)?;

if let (Some(src), Some(dst)) = (src, dst) {
self.memory.copy(src, dst, size, nonoverlapping)?;
}
Ok(())
}
}
34 changes: 1 addition & 33 deletions compiler/rustc_mir/src/interpret/step.rs
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@
//!
//! The main entry point is the `step` method.

use crate::interpret::OpTy;
use rustc_middle::mir;
use rustc_middle::mir::interpret::{InterpResult, Scalar};
use rustc_target::abi::LayoutOf;
@@ -119,7 +118,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let src = self.eval_operand(src, None)?;
let dst = self.eval_operand(dst, None)?;
let count = self.eval_operand(count, None)?;
self.copy(&src, &dst, &count, /* nonoverlapping */ true)?;
self.copy_intrinsic(&src, &dst, &count, /* nonoverlapping */ true)?;
}

// Statements we do not track.
@@ -149,37 +148,6 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(())
}

pub(crate) fn copy(
&mut self,
src: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
dst: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
count: &OpTy<'tcx, <M as Machine<'mir, 'tcx>>::PointerTag>,
nonoverlapping: bool,
) -> InterpResult<'tcx> {
let count = self.read_scalar(&count)?.to_machine_usize(self)?;
let layout = self.layout_of(src.layout.ty.builtin_deref(true).unwrap().ty)?;
let (size, align) = (layout.size, layout.align.abi);
let size = size.checked_mul(count, self).ok_or_else(|| {
err_ub_format!(
"overflow computing total size of `{}`",
if nonoverlapping { "copy_nonoverlapping" } else { "copy" }
)
})?;

// Make sure we check both pointers for an access of the total size and aligment,
// *even if* the total size is 0.
let src =
self.memory.check_ptr_access(self.read_scalar(&src)?.check_init()?, size, align)?;

let dst =
self.memory.check_ptr_access(self.read_scalar(&dst)?.check_init()?, size, align)?;

if let (Some(src), Some(dst)) = (src, dst) {
self.memory.copy(src, dst, size, nonoverlapping)?;
}
Ok(())
}

/// Evaluate an assignment statement.
///
/// There is no separate `eval_rvalue` function. Instead, the code for handling each rvalue