Skip to content

Attempt to fix tests on master #662

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

Merged
merged 2 commits into from
Jan 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 1 addition & 2 deletions ci/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ case ${TARGET} in
# proposal, but hopefully that's coming soon! For now just test that we
# can codegen with no LLVM faults, and we'll remove `--no-run` at a
# later date.
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128"
export RUSTFLAGS="${RUSTFLAGS} -Cllvm-args=-wasm-enable-unimplemented-simd"
export RUSTFLAGS="${RUSTFLAGS} -C target-feature=+simd128,+unimplemented-simd128"
cargo_test "--release --no-run"
;;
*)
Expand Down
3 changes: 2 additions & 1 deletion crates/assert-instr-macro/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ pub fn assert_instr(
.replace(':', "_")
.replace(|c: char| c.is_whitespace(), "");
let assert_name = syn::Ident::new(&format!("assert_{}_{}", name, instr_str), name.span());
let shim_name = syn::Ident::new(&format!("{}_shim", name), name.span());
let shim_name = syn::Ident::new(&format!("{}_shim_{}", name, instr_str), name.span());
let mut inputs = Vec::new();
let mut input_vals = Vec::new();
let ret = &func.decl.output;
Expand Down Expand Up @@ -99,6 +99,7 @@ pub fn assert_instr(
let shim_name_str = format!("{}{}", shim_name, assert_name);
let to_test = quote! {
#attrs
#[no_mangle]
Copy link
Contributor

@gnzlbg gnzlbg Jan 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably should add a comment around here about which exact problem #[no_mangle] solves (debug-info weirdness).

EDIT: opened #664

unsafe extern #abi fn #shim_name(#(#inputs),*) #ret {
// The compiler in optimized mode by default runs a pass called
// "mergefunc" where it'll merge functions that look identical.
Expand Down
10 changes: 0 additions & 10 deletions crates/core_arch/src/core_arch_docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -251,16 +251,6 @@ Next up let's take a look at an example of manually using intrinsics. Here
we'll be using SSE4.1 features to implement hex encoding.

```
# #![cfg_attr(not(dox),feature(stdsimd))]
# #![cfg_attr(not(dox), no_std)]
# #[cfg(not(dox))]
# extern crate std as real_std;
# #[cfg(not(dox))]
# extern crate core_arch as std;
# #[cfg(not(dox))]
# #[macro_use(is_x86_feature_detected)]
# extern crate std_detect;
Copy link
Contributor

@gnzlbg gnzlbg Jan 31, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we be doing this everywhere ? There are many doc examples where we do this dance. EDIT: I see some more of this below, sorry about the noise!

EDIT2: so grepping for "real_std" reveals still some occurrences of this. I am not sure exactly why this change was needed here but not everywhere else.

Opened: #665

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I don't really know what was happening to have the doctests fail, but this is all in std now so none of this was necessary any more


fn main() {
let mut dst = [0; 32];
hex_encode(b"\x01\x02\x03", &mut dst);
Expand Down
1 change: 0 additions & 1 deletion crates/core_arch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#![doc(include = "core_arch_docs.md")]

#![cfg_attr(stdsimd_strict, deny(warnings))]
#![allow(dead_code)]
#![allow(unused_features)]
Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/wasm32/simd128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ pub fn i8x16_splat(a: i8) -> v128 {
#[rustc_args_required_const(1)]
pub unsafe fn i8x16_extract_lane(a: v128, imm: usize) -> i8 {
#[cfg(test)]
#[assert_instr(i16x8.extract_lane_s)]
#[assert_instr(i8x16.extract_lane_s)]
fn extract_lane_s(a: v128) -> i32 {
unsafe { i8x16_extract_lane(a, 0) as i32 }
}
Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/x86/bmi2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use stdsimd_test::assert_instr;
#[inline]
// LLVM BUG (should be mulxl): https://bugs.llvm.org/show_bug.cgi?id=34232
#[cfg_attr(all(test, target_arch = "x86_64"), assert_instr(imul))]
#[cfg_attr(all(test, target_arch = "x86"), assert_instr(mulx))]
#[cfg_attr(all(test, target_arch = "x86"), assert_instr(mul))]
#[target_feature(enable = "bmi2")]
#[stable(feature = "simd_x86", since = "1.27.0")]
pub unsafe fn _mulx_u32(a: u32, b: u32, hi: &mut u32) -> u32 {
Expand Down
62 changes: 0 additions & 62 deletions crates/core_arch/src/x86/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,6 @@ types! {
///
/// ```
/// # #![feature(stdsimd, mmx_target_feature)]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -85,15 +77,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -131,15 +114,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -177,15 +151,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -227,15 +192,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -273,15 +229,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down Expand Up @@ -319,15 +266,6 @@ types! {
/// # Examples
///
/// ```
/// # #![cfg_attr(not(dox), feature(stdsimd))]
/// # #![cfg_attr(not(dox), no_std)]
/// # #[cfg(not(dox))]
/// # extern crate std as real_std;
/// # #[cfg(not(dox))]
/// # extern crate core_arch as std;
/// # #[cfg(not(dox))]
/// # #[macro_use(is_x86_feature_detected)]
/// # extern crate std_detect;
/// #[cfg(target_arch = "x86")]
/// use std::arch::x86::*;
/// #[cfg(target_arch = "x86_64")]
Expand Down
2 changes: 1 addition & 1 deletion crates/core_arch/src/x86_64/bmi2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use stdsimd_test::assert_instr;
///
/// [Intel's documentation](https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=_mulx_u64)
#[inline]
#[cfg_attr(test, assert_instr(mulx))]
#[cfg_attr(test, assert_instr(mul))]
#[target_feature(enable = "bmi2")]
#[cfg(not(target_arch = "x86"))] // calls an intrinsic
#[stable(feature = "simd_x86", since = "1.27.0")]
Expand Down
8 changes: 7 additions & 1 deletion crates/stdsimd-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,16 @@ struct Instruction {

fn normalize(symbol: &str) -> String {
let symbol = rustc_demangle::demangle(symbol).to_string();
match symbol.rfind("::h") {
let mut ret = match symbol.rfind("::h") {
Some(i) => symbol[..i].to_string(),
None => symbol.to_string(),
};
// Normalize to no leading underscore to handle platforms that may
// inject extra ones in symbol names
while ret.starts_with("_") {
ret.remove(0);
}
return ret;
}

/// Main entry point for this crate, called by the `#[assert_instr]` macro.
Expand Down
4 changes: 2 additions & 2 deletions crates/stdsimd-test/src/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ pub(crate) fn disassemble_myself() -> HashMap<String, Vec<Function>> {
let mut parts = line.split_whitespace().skip(3);
let offset = parts.next()
.unwrap()
.trim_right_matches(")")
.trim_end_matches(")")
.parse::<usize>()
.unwrap();
for (i, name) in parts.enumerate() {
let name = name.trim_right_matches(")");
let name = name.trim_end_matches(")");
for f in ret.get_mut(name).expect("ret.get_mut(name) failed") {
f.addr = Some(i + offset);
}
Expand Down