Skip to content

Rollup of 10 pull requests #74245

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 29 commits into from
Jul 12, 2020
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
f8eb81b
Modify type names on MSVC to make tuples .natvis compatible.
MaulingMonkey Jun 25, 2020
24a728a
debuginfo: Define int/float types in terms of MSVC-recognized types.
MaulingMonkey Jun 25, 2020
980d8e1
Optimize is_ascii for &str and &[u8]
Jul 5, 2020
63e2e2e
Avoid `vec!` allocation in `is_ascii_slice_*` benches
Jul 5, 2020
e1d4db6
Add benchmark for slice is_ascii using align_to
Jul 5, 2020
13e380d
Benchmark the unaligned case for is_ascii, and add missing SAFETY
Jul 5, 2020
dc4a644
Add 'unrolled' is_ascii_align_to benchmark, and move is_ascii benchma…
Jul 5, 2020
a150dcc
Remove pointless `black_box` call, add a comment about the `unaligned…
Jul 6, 2020
59f979f
Fix cross-compilation of LLVM to aarch64 Windows targets
arlosi Jul 2, 2020
7fb421b
linker: illumos ld does not support --eh-frame-hdr
jclulow Jul 8, 2020
520fb92
Reword incorrect `self` token suggestion
estebank Jul 9, 2020
6864546
Add a help to use `in_band_lifetimes` in nightly
JohnTitor Jul 8, 2020
a9b6476
Tweak wording
JohnTitor Jul 9, 2020
1fb0ed0
Minor refactor for rustc_resolve diagnostics match
pickfire Jul 10, 2020
dd872be
Stabilize `transmute` in constants and statics but not const fn
oli-obk Aug 30, 2019
b929f72
Fix try_print_visible_def_path_recur for opt_def_id usage
da-x Jul 11, 2020
6bda2e8
update miri
RalfJung Jul 11, 2020
f5de23b
Add the test case mentioned in #74236
da-x Jul 11, 2020
90f1d72
Rollup merge of #72920 - oli-obk:const_transmute, r=RalfJung
Manishearth Jul 11, 2020
084ac77
Rollup merge of #73715 - MaulingMonkey:pr-natvis-tuples, r=Amanieu
Manishearth Jul 11, 2020
1979fa8
Rollup merge of #74066 - thomcc:optimize-is-ascii, r=nagisa
Manishearth Jul 11, 2020
9614238
Rollup merge of #74116 - arlosi:aarch64build, r=pietroalbini
Manishearth Jul 11, 2020
8f8ff15
Rollup merge of #74167 - jclulow:illumos-linker-eh-frame-hdr-fix, r=p…
Manishearth Jul 11, 2020
9f7b64e
Rollup merge of #74168 - JohnTitor:help-for-in-band-lifetimes, r=petr…
Manishearth Jul 11, 2020
e15fa45
Rollup merge of #74197 - estebank:self-sugg, r=petrochenkov
Manishearth Jul 11, 2020
6204a73
Rollup merge of #74213 - pickfire:patch-1, r=jonas-schievink
Manishearth Jul 11, 2020
aa04ffb
Rollup merge of #74240 - da-x:fix-74081, r=Manishearth
Manishearth Jul 11, 2020
95c5fb8
Rollup merge of #74241 - RalfJung:miri, r=RalfJung
Manishearth Jul 11, 2020
c8c4fd7
Correctly sort const_fn_transmute
Manishearth Jul 11, 2020
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
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
@@ -404,9 +404,9 @@ version = "0.1.0"

[[package]]
name = "cc"
version = "1.0.54"
version = "1.0.57"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311"
checksum = "0fde55d2a2bfaa4c9668bbc63f531fbdeee3ffe188f4662511ce2c22b3eedebe"
dependencies = [
"jobserver",
]
31 changes: 23 additions & 8 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
//! ensure that they're always in place if needed.

use std::env;
use std::env::consts::EXE_EXTENSION;
use std::ffi::OsString;
use std::fs::{self, File};
use std::io;
@@ -252,8 +253,14 @@ impl Step for Llvm {
// FIXME: if the llvm root for the build triple is overridden then we
// should use llvm-tblgen from there, also should verify that it
// actually exists most of the time in normal installs of LLVM.
let host = builder.llvm_out(builder.config.build).join("bin/llvm-tblgen");
cfg.define("CMAKE_CROSSCOMPILING", "True").define("LLVM_TABLEGEN", &host);
let host_bin = builder.llvm_out(builder.config.build).join("bin");
cfg.define("CMAKE_CROSSCOMPILING", "True");
cfg.define("LLVM_TABLEGEN", host_bin.join("llvm-tblgen").with_extension(EXE_EXTENSION));
cfg.define("LLVM_NM", host_bin.join("llvm-nm").with_extension(EXE_EXTENSION));
cfg.define(
"LLVM_CONFIG_PATH",
host_bin.join("llvm-config").with_extension(EXE_EXTENSION),
);

if target.contains("netbsd") {
cfg.define("CMAKE_SYSTEM_NAME", "NetBSD");
@@ -262,8 +269,6 @@ impl Step for Llvm {
} else if target.contains("windows") {
cfg.define("CMAKE_SYSTEM_NAME", "Windows");
}

cfg.define("LLVM_NATIVE_BUILD", builder.llvm_out(builder.config.build).join("build"));
}

if let Some(ref suffix) = builder.config.llvm_version_suffix {
@@ -431,6 +436,9 @@ fn configure_cmake(
cflags.push_str(" -miphoneos-version-min=10.0");
}
}
if builder.config.llvm_clang_cl.is_some() {
cflags.push_str(&format!(" --target={}", target))
}
cfg.define("CMAKE_C_FLAGS", cflags);
let mut cxxflags = builder.cflags(target, GitRepo::Llvm).join(" ");
if builder.config.llvm_static_stdcpp && !target.contains("msvc") && !target.contains("netbsd") {
@@ -439,6 +447,9 @@ fn configure_cmake(
if let Some(ref s) = builder.config.llvm_cxxflags {
cxxflags.push_str(&format!(" {}", s));
}
if builder.config.llvm_clang_cl.is_some() {
cxxflags.push_str(&format!(" --target={}", target))
}
cfg.define("CMAKE_CXX_FLAGS", cxxflags);
if let Some(ar) = builder.ar(target) {
if ar.is_absolute() {
@@ -484,7 +495,7 @@ impl Step for Lld {
run.builder.ensure(Lld { target: run.target });
}

/// Compile LLVM for `target`.
/// Compile LLD for `target`.
fn run(self, builder: &Builder<'_>) -> PathBuf {
if builder.config.dry_run {
return PathBuf::from("lld-out-dir-test-gen");
@@ -521,6 +532,7 @@ impl Step for Lld {
// can't build on a system where your paths require `\` on Windows, but
// there's probably a lot of reasons you can't do that other than this.
let llvm_config_shim = env::current_exe().unwrap().with_file_name("llvm-config-wrapper");

cfg.out_dir(&out_dir)
.profile("Release")
.env("LLVM_CONFIG_REAL", &llvm_config)
@@ -543,7 +555,10 @@ impl Step for Lld {
if target != builder.config.build {
cfg.env("LLVM_CONFIG_SHIM_REPLACE", &builder.config.build)
.env("LLVM_CONFIG_SHIM_REPLACE_WITH", &target)
.define("LLVM_TABLEGEN_EXE", llvm_config.with_file_name("llvm-tblgen"));
.define(
"LLVM_TABLEGEN_EXE",
llvm_config.with_file_name("llvm-tblgen").with_extension(EXE_EXTENSION),
);
}

// Explicitly set C++ standard, because upstream doesn't do so
@@ -595,8 +610,8 @@ impl Step for TestHelpers {
}

// We may have found various cross-compilers a little differently due to our
// extra configuration, so inform gcc of these compilers. Note, though, that
// on MSVC we still need gcc's detection of env vars (ugh).
// extra configuration, so inform cc of these compilers. Note, though, that
// on MSVC we still need cc's detection of env vars (ugh).
if !target.contains("msvc") {
if let Some(ar) = builder.ar(target) {
cfg.archiver(ar);
124 changes: 124 additions & 0 deletions src/etc/natvis/intrinsic.natvis
Original file line number Diff line number Diff line change
@@ -21,4 +21,128 @@
</ArrayItems>
</Expand>
</Type>
<Type Name="tuple&lt;&gt;">
<DisplayString>()</DisplayString>
</Type>
<Type Name="tuple&lt;*&gt;">
<DisplayString>({__0})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*&gt;">
<DisplayString>({__0}, {__1})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
<Item Name="[6]">__6</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
<Item Name="[6]">__6</Item>
<Item Name="[7]">__7</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
<Item Name="[6]">__6</Item>
<Item Name="[7]">__7</Item>
<Item Name="[8]">__8</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9})</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
<Item Name="[6]">__6</Item>
<Item Name="[7]">__7</Item>
<Item Name="[8]">__8</Item>
<Item Name="[9]">__9</Item>
</Expand>
</Type>
<Type Name="tuple&lt;*,*,*,*,*,*,*,*,*,*,*&gt;">
<DisplayString>({__0}, {__1}, {__2}, {__3}, {__4}, {__5}, {__6}, {__7}, {__8}, {__9}, ...)</DisplayString>
<Expand>
<Item Name="[0]">__0</Item>
<Item Name="[1]">__1</Item>
<Item Name="[2]">__2</Item>
<Item Name="[3]">__3</Item>
<Item Name="[4]">__4</Item>
<Item Name="[5]">__5</Item>
<Item Name="[6]">__6</Item>
<Item Name="[7]">__7</Item>
<Item Name="[8]">__8</Item>
<Item Name="[9]">__9</Item>
<Synthetic Name="[...]"><DisplayString>...</DisplayString></Synthetic>
</Expand>
</Type>
</AutoVisualizer>
2 changes: 2 additions & 0 deletions src/libcore/benches/ascii.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
mod is_ascii;

// Lower-case ASCII 'a' is the first byte that has its highest bit set
// after wrap-adding 0x1F:
//
82 changes: 82 additions & 0 deletions src/libcore/benches/ascii/is_ascii.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
use super::{LONG, MEDIUM, SHORT};
use test::black_box;
use test::Bencher;

macro_rules! benches {
($( fn $name: ident($arg: ident: &[u8]) $body: block )+) => {
benches!(mod short SHORT[..] $($name $arg $body)+);
benches!(mod medium MEDIUM[..] $($name $arg $body)+);
benches!(mod long LONG[..] $($name $arg $body)+);
// Ensure we benchmark cases where the functions are called with strings
// that are not perfectly aligned or have a length which is not a
// multiple of size_of::<usize>() (or both)
benches!(mod unaligned_head MEDIUM[1..] $($name $arg $body)+);
benches!(mod unaligned_tail MEDIUM[..(MEDIUM.len() - 1)] $($name $arg $body)+);
benches!(mod unaligned_both MEDIUM[1..(MEDIUM.len() - 1)] $($name $arg $body)+);
};

(mod $mod_name: ident $input: ident [$range: expr] $($name: ident $arg: ident $body: block)+) => {
mod $mod_name {
use super::*;
$(
#[bench]
fn $name(bencher: &mut Bencher) {
bencher.bytes = $input[$range].len() as u64;
let mut vec = $input.as_bytes().to_vec();
bencher.iter(|| {
let $arg: &[u8] = &black_box(&mut vec)[$range];
black_box($body)
})
}
)+
}
};
}

benches! {
fn case00_libcore(bytes: &[u8]) {
bytes.is_ascii()
}

fn case01_iter_all(bytes: &[u8]) {
bytes.iter().all(|b| b.is_ascii())
}

fn case02_align_to(bytes: &[u8]) {
is_ascii_align_to(bytes)
}

fn case03_align_to_unrolled(bytes: &[u8]) {
is_ascii_align_to_unrolled(bytes)
}
}

// These are separate since it's easier to debug errors if they don't go through
// macro expansion first.
fn is_ascii_align_to(bytes: &[u8]) -> bool {
if bytes.len() < core::mem::size_of::<usize>() {
return bytes.iter().all(|b| b.is_ascii());
}
// SAFETY: transmuting a sequence of `u8` to `usize` is always fine
let (head, body, tail) = unsafe { bytes.align_to::<usize>() };
head.iter().all(|b| b.is_ascii())
&& body.iter().all(|w| !contains_nonascii(*w))
&& tail.iter().all(|b| b.is_ascii())
}

fn is_ascii_align_to_unrolled(bytes: &[u8]) -> bool {
if bytes.len() < core::mem::size_of::<usize>() {
return bytes.iter().all(|b| b.is_ascii());
}
// SAFETY: transmuting a sequence of `u8` to `[usize; 2]` is always fine
let (head, body, tail) = unsafe { bytes.align_to::<[usize; 2]>() };
head.iter().all(|b| b.is_ascii())
&& body.iter().all(|w| !contains_nonascii(w[0] | w[1]))
&& tail.iter().all(|b| b.is_ascii())
}

#[inline]
fn contains_nonascii(v: usize) -> bool {
const NONASCII_MASK: usize = 0x80808080_80808080u64 as usize;
(NONASCII_MASK & v) != 0
}
4 changes: 3 additions & 1 deletion src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
@@ -1285,7 +1285,9 @@ extern "rust-intrinsic" {
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_transmute", issue = "53605")]
// NOTE: While this makes the intrinsic const stable, we have some custom code in const fn
// checks that prevent its use within `const fn`.
#[rustc_const_stable(feature = "const_transmute", since = "1.46.0")]
pub fn transmute<T, U>(e: T) -> U;

/// Returns `true` if the actual type given as `T` requires drop
2 changes: 1 addition & 1 deletion src/libcore/lib.rs
Original file line number Diff line number Diff line change
@@ -140,7 +140,7 @@
#![feature(rtm_target_feature)]
#![feature(f16c_target_feature)]
#![feature(hexagon_target_feature)]
#![feature(const_transmute)]
#![cfg_attr(not(bootstrap), feature(const_fn_transmute))]
#![feature(abi_unadjusted)]
#![feature(adx_target_feature)]
#![feature(maybe_uninit_slice)]
Loading