From 3de76d47a23eda3fe6a79155bca1f16bfd16f928 Mon Sep 17 00:00:00 2001 From: sayantn Date: Wed, 28 May 2025 02:08:46 +0530 Subject: [PATCH] Use the new definition of `rdtscp` intrinsic - add `-Zverify-llvm-ir` in testsuite --- library/stdarch/ci/run.sh | 2 +- library/stdarch/crates/core_arch/src/x86/rdtsc.rs | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/library/stdarch/ci/run.sh b/library/stdarch/ci/run.sh index fd7ec81d505c..8eadb9285c99 100755 --- a/library/stdarch/ci/run.sh +++ b/library/stdarch/ci/run.sh @@ -10,7 +10,7 @@ set -ex #export RUST_TEST_NOCAPTURE=1 #export RUST_TEST_THREADS=1 -export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled " +export RUSTFLAGS="${RUSTFLAGS} -D warnings -Z merge-functions=disabled -Z verify-llvm-ir" export HOST_RUSTFLAGS="${RUSTFLAGS}" export PROFILE="${PROFILE:="--profile=release"}" diff --git a/library/stdarch/crates/core_arch/src/x86/rdtsc.rs b/library/stdarch/crates/core_arch/src/x86/rdtsc.rs index e714aa863b95..3b348153d602 100644 --- a/library/stdarch/crates/core_arch/src/x86/rdtsc.rs +++ b/library/stdarch/crates/core_arch/src/x86/rdtsc.rs @@ -46,15 +46,17 @@ pub unsafe fn _rdtsc() -> u64 { #[cfg_attr(test, assert_instr(rdtscp))] #[stable(feature = "simd_x86", since = "1.27.0")] pub unsafe fn __rdtscp(aux: *mut u32) -> u64 { - rdtscp(aux as *mut _) + let (tsc, auxval) = rdtscp(); + *aux = auxval; + tsc } #[allow(improper_ctypes)] -unsafe extern "C" { +unsafe extern "unadjusted" { #[link_name = "llvm.x86.rdtsc"] fn rdtsc() -> u64; #[link_name = "llvm.x86.rdtscp"] - fn rdtscp(aux: *mut u8) -> u64; + fn rdtscp() -> (u64, u32); } #[cfg(test)]