Skip to content

Commit 0462e8f

Browse files
committed
Auto merge of #151667 - Zalathar:rollup-OzG0S5m, r=Zalathar
Rollup of 6 pull requests Successful merges: - #151611 (Improve is_ascii performance on x86_64 with explicit SSE2 intrinsics) - #150705 (Add missing mut to pin.rs docs) - #151294 (compiletest: add implied `needs-target-std` for `codegen` mode tests unless annotated with `#![no_std]`/`#![no_core]`) - #151589 (Add a `documentation` remapping path scope for rustdoc usage) - #151639 (Fix broken WASIp1 reference link) - #151645 (Update `sysinfo` version to `0.38.0`)
2 parents fb292b7 + ec48041 commit 0462e8f

36 files changed

+532
-119
lines changed

Cargo.lock

Lines changed: 66 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ dependencies = [
857857
"tracing-subscriber",
858858
"unified-diff",
859859
"walkdir",
860-
"windows",
860+
"windows 0.61.3",
861861
]
862862

863863
[[package]]
@@ -2038,7 +2038,7 @@ dependencies = [
20382038
"serde",
20392039
"tempfile",
20402040
"uuid",
2041-
"windows",
2041+
"windows 0.61.3",
20422042
]
20432043

20442044
[[package]]
@@ -3698,7 +3698,7 @@ dependencies = [
36983698
"thorin-dwp",
36993699
"tracing",
37003700
"wasm-encoder 0.219.2",
3701-
"windows",
3701+
"windows 0.61.3",
37023702
]
37033703

37043704
[[package]]
@@ -3756,7 +3756,7 @@ dependencies = [
37563756
"tempfile",
37573757
"thin-vec",
37583758
"tracing",
3759-
"windows",
3759+
"windows 0.61.3",
37603760
]
37613761

37623762
[[package]]
@@ -3822,7 +3822,7 @@ dependencies = [
38223822
"serde_json",
38233823
"shlex",
38243824
"tracing",
3825-
"windows",
3825+
"windows 0.61.3",
38263826
]
38273827

38283828
[[package]]
@@ -3873,7 +3873,7 @@ dependencies = [
38733873
"serde_json",
38743874
"termize",
38753875
"tracing",
3876-
"windows",
3876+
"windows 0.61.3",
38773877
]
38783878

38793879
[[package]]
@@ -4664,7 +4664,7 @@ dependencies = [
46644664
"rustc_target",
46654665
"termize",
46664666
"tracing",
4667-
"windows",
4667+
"windows 0.61.3",
46684668
]
46694669

46704670
[[package]]
@@ -5438,14 +5438,14 @@ dependencies = [
54385438

54395439
[[package]]
54405440
name = "sysinfo"
5441-
version = "0.37.2"
5441+
version = "0.38.0"
54425442
source = "registry+https://github.com/rust-lang/crates.io-index"
5443-
checksum = "16607d5caffd1c07ce073528f9ed972d88db15dd44023fa57142963be3feb11f"
5443+
checksum = "fe840c5b1afe259a5657392a4dbb74473a14c8db999c3ec2f4ae812e028a94da"
54445444
dependencies = [
54455445
"libc",
54465446
"objc2-core-foundation",
54475447
"objc2-io-kit",
5448-
"windows",
5448+
"windows 0.62.2",
54495449
]
54505450

54515451
[[package]]
@@ -6398,11 +6398,23 @@ version = "0.61.3"
63986398
source = "registry+https://github.com/rust-lang/crates.io-index"
63996399
checksum = "9babd3a767a4c1aef6900409f85f5d53ce2544ccdfaa86dad48c91782c6d6893"
64006400
dependencies = [
6401-
"windows-collections",
6401+
"windows-collections 0.2.0",
64026402
"windows-core 0.61.2",
6403-
"windows-future",
6403+
"windows-future 0.2.1",
64046404
"windows-link 0.1.3",
6405-
"windows-numerics",
6405+
"windows-numerics 0.2.0",
6406+
]
6407+
6408+
[[package]]
6409+
name = "windows"
6410+
version = "0.62.2"
6411+
source = "registry+https://github.com/rust-lang/crates.io-index"
6412+
checksum = "527fadee13e0c05939a6a05d5bd6eec6cd2e3dbd648b9f8e447c6518133d8580"
6413+
dependencies = [
6414+
"windows-collections 0.3.2",
6415+
"windows-core 0.62.2",
6416+
"windows-future 0.3.2",
6417+
"windows-numerics 0.3.1",
64066418
]
64076419

64086420
[[package]]
@@ -6413,7 +6425,7 @@ checksum = "9b4e97b01190d32f268a2dfbd3f006f77840633746707fbe40bcee588108a231"
64136425
dependencies = [
64146426
"serde",
64156427
"serde_json",
6416-
"windows-threading",
6428+
"windows-threading 0.1.0",
64176429
]
64186430

64196431
[[package]]
@@ -6425,6 +6437,15 @@ dependencies = [
64256437
"windows-core 0.61.2",
64266438
]
64276439

6440+
[[package]]
6441+
name = "windows-collections"
6442+
version = "0.3.2"
6443+
source = "registry+https://github.com/rust-lang/crates.io-index"
6444+
checksum = "23b2d95af1a8a14a3c7367e1ed4fc9c20e0a26e79551b1454d72583c97cc6610"
6445+
dependencies = [
6446+
"windows-core 0.62.2",
6447+
]
6448+
64286449
[[package]]
64296450
name = "windows-core"
64306451
version = "0.61.2"
@@ -6459,7 +6480,18 @@ checksum = "fc6a41e98427b19fe4b73c550f060b59fa592d7d686537eebf9385621bfbad8e"
64596480
dependencies = [
64606481
"windows-core 0.61.2",
64616482
"windows-link 0.1.3",
6462-
"windows-threading",
6483+
"windows-threading 0.1.0",
6484+
]
6485+
6486+
[[package]]
6487+
name = "windows-future"
6488+
version = "0.3.2"
6489+
source = "registry+https://github.com/rust-lang/crates.io-index"
6490+
checksum = "e1d6f90251fe18a279739e78025bd6ddc52a7e22f921070ccdc67dde84c605cb"
6491+
dependencies = [
6492+
"windows-core 0.62.2",
6493+
"windows-link 0.2.1",
6494+
"windows-threading 0.2.1",
64636495
]
64646496

64656497
[[package]]
@@ -6506,6 +6538,16 @@ dependencies = [
65066538
"windows-link 0.1.3",
65076539
]
65086540

6541+
[[package]]
6542+
name = "windows-numerics"
6543+
version = "0.3.1"
6544+
source = "registry+https://github.com/rust-lang/crates.io-index"
6545+
checksum = "6e2e40844ac143cdb44aead537bbf727de9b044e107a0f1220392177d15b0f26"
6546+
dependencies = [
6547+
"windows-core 0.62.2",
6548+
"windows-link 0.2.1",
6549+
]
6550+
65096551
[[package]]
65106552
name = "windows-result"
65116553
version = "0.3.4"
@@ -6611,6 +6653,15 @@ dependencies = [
66116653
"windows-link 0.1.3",
66126654
]
66136655

6656+
[[package]]
6657+
name = "windows-threading"
6658+
version = "0.2.1"
6659+
source = "registry+https://github.com/rust-lang/crates.io-index"
6660+
checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37"
6661+
dependencies = [
6662+
"windows-link 0.2.1",
6663+
]
6664+
66146665
[[package]]
66156666
name = "windows_aarch64_gnullvm"
66166667
version = "0.52.6"

compiler/rustc_session/src/config.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1322,18 +1322,26 @@ impl OutputFilenames {
13221322
pub(crate) fn parse_remap_path_scope(
13231323
early_dcx: &EarlyDiagCtxt,
13241324
matches: &getopts::Matches,
1325+
unstable_opts: &UnstableOptions,
13251326
) -> RemapPathScopeComponents {
13261327
if let Some(v) = matches.opt_str("remap-path-scope") {
13271328
let mut slot = RemapPathScopeComponents::empty();
13281329
for s in v.split(',') {
13291330
slot |= match s {
13301331
"macro" => RemapPathScopeComponents::MACRO,
13311332
"diagnostics" => RemapPathScopeComponents::DIAGNOSTICS,
1333+
"documentation" => {
1334+
if !unstable_opts.unstable_options {
1335+
early_dcx.early_fatal("remapping `documentation` path scope requested but `-Zunstable-options` not specified");
1336+
}
1337+
1338+
RemapPathScopeComponents::DOCUMENTATION
1339+
},
13321340
"debuginfo" => RemapPathScopeComponents::DEBUGINFO,
13331341
"coverage" => RemapPathScopeComponents::COVERAGE,
13341342
"object" => RemapPathScopeComponents::OBJECT,
13351343
"all" => RemapPathScopeComponents::all(),
1336-
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `debuginfo`, `coverage`, `object`, `all`"),
1344+
_ => early_dcx.early_fatal("argument for `--remap-path-scope` must be a comma separated list of scopes: `macro`, `diagnostics`, `documentation`, `debuginfo`, `coverage`, `object`, `all`"),
13371345
}
13381346
}
13391347
slot
@@ -2677,7 +2685,7 @@ pub fn build_session_options(early_dcx: &mut EarlyDiagCtxt, matches: &getopts::M
26772685
let externs = parse_externs(early_dcx, matches, &unstable_opts);
26782686

26792687
let remap_path_prefix = parse_remap_path_prefix(early_dcx, matches, &unstable_opts);
2680-
let remap_path_scope = parse_remap_path_scope(early_dcx, matches);
2688+
let remap_path_scope = parse_remap_path_scope(early_dcx, matches, &unstable_opts);
26812689

26822690
let pretty = parse_pretty(early_dcx, &unstable_opts);
26832691

compiler/rustc_span/src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ bitflags::bitflags! {
233233
const DEBUGINFO = 1 << 3;
234234
/// Apply remappings to coverage information
235235
const COVERAGE = 1 << 4;
236+
/// Apply remappings to documentation information
237+
const DOCUMENTATION = 1 << 5;
236238

237239
/// An alias for `macro`, `debuginfo` and `coverage`. This ensures all paths in compiled
238240
/// executables, libraries and objects are remapped but not elsewhere.

library/core/src/pin.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -831,15 +831,13 @@
831831
//! <code>fn get_pin_mut(self: [Pin]<[`&mut Self`]>) -> [Pin]<[`&mut T`]></code>.
832832
//! Then we could do the following:
833833
//! ```compile_fail
834-
//! # use std::cell::RefCell;
835-
//! # use std::pin::Pin;
836-
//! fn exploit_ref_cell<T>(rc: Pin<&mut RefCell<T>>) {
834+
//! fn exploit_ref_cell<T>(mut rc: Pin<&mut RefCell<T>>) {
837835
//! // Here we get pinned access to the `T`.
838836
//! let _: Pin<&mut T> = rc.as_mut().get_pin_mut();
839837
//!
840838
//! // And here we have `&mut T` to the same data.
841839
//! let shared: &RefCell<T> = rc.into_ref().get_ref();
842-
//! let borrow = shared.borrow_mut();
840+
//! let mut borrow = shared.borrow_mut();
843841
//! let content = &mut *borrow;
844842
//! }
845843
//! ```

library/core/src/slice/ascii.rs

Lines changed: 22 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -460,56 +460,38 @@ const fn is_ascii(s: &[u8]) -> bool {
460460
)
461461
}
462462

463-
/// Chunk size for vectorized ASCII checking (two 16-byte SSE registers).
463+
/// Chunk size for SSE2 vectorized ASCII checking (4x 16-byte loads).
464464
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))]
465-
const CHUNK_SIZE: usize = 32;
465+
const SSE2_CHUNK_SIZE: usize = 64;
466466

467-
/// SSE2 implementation using `_mm_movemask_epi8` (compiles to `pmovmskb`) to
468-
/// avoid LLVM's broken AVX-512 auto-vectorization of counting loops.
469-
///
470-
/// FIXME(llvm#176906): Remove this workaround once LLVM generates efficient code.
471467
#[cfg(all(target_arch = "x86_64", target_feature = "sse2"))]
468+
#[inline]
472469
fn is_ascii_sse2(bytes: &[u8]) -> bool {
473470
use crate::arch::x86_64::{__m128i, _mm_loadu_si128, _mm_movemask_epi8, _mm_or_si128};
474471

475-
let mut i = 0;
476-
477-
while i + CHUNK_SIZE <= bytes.len() {
478-
// SAFETY: We have verified that `i + CHUNK_SIZE <= bytes.len()`.
479-
let ptr = unsafe { bytes.as_ptr().add(i) };
480-
481-
// Load two 16-byte chunks and combine them.
482-
// SAFETY: We verified `i + 32 <= len`, so ptr is valid for 32 bytes.
483-
// `_mm_loadu_si128` allows unaligned loads.
484-
let chunk1 = unsafe { _mm_loadu_si128(ptr as *const __m128i) };
485-
// SAFETY: Same as above - ptr.add(16) is within the valid 32-byte range.
486-
let chunk2 = unsafe { _mm_loadu_si128(ptr.add(16) as *const __m128i) };
487-
488-
// OR them together - if any byte has the high bit set, the result will too.
489-
// SAFETY: SSE2 is guaranteed by the cfg predicate.
490-
let combined = unsafe { _mm_or_si128(chunk1, chunk2) };
491-
492-
// Create a mask from the MSBs of each byte.
493-
// If any byte is >= 128, its MSB is 1, so the mask will be non-zero.
494-
// SAFETY: SSE2 is guaranteed by the cfg predicate.
495-
let mask = unsafe { _mm_movemask_epi8(combined) };
496-
472+
let (chunks, rest) = bytes.as_chunks::<SSE2_CHUNK_SIZE>();
473+
474+
for chunk in chunks {
475+
let ptr = chunk.as_ptr();
476+
// SAFETY: chunk is 64 bytes. SSE2 is baseline on x86_64.
477+
let mask = unsafe {
478+
let a1 = _mm_loadu_si128(ptr as *const __m128i);
479+
let a2 = _mm_loadu_si128(ptr.add(16) as *const __m128i);
480+
let b1 = _mm_loadu_si128(ptr.add(32) as *const __m128i);
481+
let b2 = _mm_loadu_si128(ptr.add(48) as *const __m128i);
482+
// OR all chunks - if any byte has high bit set, combined will too.
483+
let combined = _mm_or_si128(_mm_or_si128(a1, a2), _mm_or_si128(b1, b2));
484+
// Create a mask from the MSBs of each byte.
485+
// If any byte is >= 128, its MSB is 1, so the mask will be non-zero.
486+
_mm_movemask_epi8(combined)
487+
};
497488
if mask != 0 {
498489
return false;
499490
}
500-
501-
i += CHUNK_SIZE;
502-
}
503-
504-
// Handle remaining bytes with simple loop
505-
while i < bytes.len() {
506-
if !bytes[i].is_ascii() {
507-
return false;
508-
}
509-
i += 1;
510491
}
511492

512-
true
493+
// Handle remaining bytes
494+
rest.iter().all(|b| b.is_ascii())
513495
}
514496

515497
/// ASCII test optimized to use the `pmovmskb` instruction on `x86-64`.
@@ -529,7 +511,7 @@ const fn is_ascii(bytes: &[u8]) -> bool {
529511
is_ascii_simple(bytes)
530512
} else {
531513
// For small inputs, use usize-at-a-time processing to avoid SSE2 call overhead.
532-
if bytes.len() < CHUNK_SIZE {
514+
if bytes.len() < SSE2_CHUNK_SIZE {
533515
let chunks = bytes.chunks_exact(USIZE_SIZE);
534516
let remainder = chunks.remainder();
535517
for chunk in chunks {

0 commit comments

Comments
 (0)