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 9 pull requests #94557

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
7cee1b4
ARM: Only allow using d16-d31 with asm! when supported by the target
Amanieu Feb 24, 2022
2d854f9
Remove num_cpus dependency from bootstrap, build-manifest and rustc_s…
bjorn3 Mar 2, 2022
78e7d9b
Re-enable debuginfo tests that have been ignored
wesleywiser Mar 1, 2022
926bf1a
Pass LLVM string attributes as string slices
tmiasko Mar 3, 2022
bac5523
Use cgroup quotas for calculating `available_parallelism`
the8472 Jan 9, 2022
af6d2ed
hardcode /sys/fs/cgroup instead of doing a lookup via mountinfo
the8472 Mar 2, 2022
e18abbf
update available_parallelism docs since cgroups and sched_getaffinity…
the8472 Mar 2, 2022
37c1eb0
Doc: Fix use of quote instead of backstick in Adapter::map.
darnuria Mar 3, 2022
11c565f
Improve if/else formatting in macro_parser.rs.
nnethercote Mar 3, 2022
b9fabc3
Add a static size assertion for `MatcherPos`.
nnethercote Mar 3, 2022
643ba50
Introduce `MatcherPosRepetition`.
nnethercote Mar 3, 2022
e5f3fd6
Use a better return type for `inner_parse_loop`.
nnethercote Mar 3, 2022
97eb1b4
Change `initial_matcher_pos()` into `MatcherPos::new()`.
nnethercote Mar 3, 2022
5164884
Fix invalid lint_node_id being put on a removed stmt
Urgau Mar 3, 2022
00fffdd
all: fix some typos
cuishuang Mar 3, 2022
3edda1a
Rollup merge of #92697 - the8472:cgroups, r=joshtriplett
Dylan-DPC Mar 3, 2022
1ff1ebc
Rollup merge of #94339 - Amanieu:arm-d32, r=nagisa
Dylan-DPC Mar 3, 2022
67b3d5f
Rollup merge of #94489 - wesleywiser:enable_some_debuginfo_tests, r=M…
Dylan-DPC Mar 3, 2022
4fc43d7
Rollup merge of #94524 - bjorn3:remove_num_cpus, r=Mark-Simulacrum
Dylan-DPC Mar 3, 2022
b56c1d8
Rollup merge of #94539 - tmiasko:string-attributes, r=nikic
Dylan-DPC Mar 3, 2022
6dbc9e2
Rollup merge of #94547 - nnethercote:parse_tt-cleanups, r=petrochenkov
Dylan-DPC Mar 3, 2022
c0e1fd7
Rollup merge of #94551 - darnuria:doc-map-backstick, r=dtolnay
Dylan-DPC Mar 3, 2022
2f84a84
Rollup merge of #94554 - Urgau:stmt-node-id-ice, r=petrochenkov
Dylan-DPC Mar 3, 2022
3b53713
Rollup merge of #94555 - cuishuang:master, r=oli-obk
Dylan-DPC Mar 3, 2022
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: 0 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ dependencies = [
"getopts",
"ignore",
"libc",
"num_cpus",
"once_cell",
"opener",
"pretty_assertions",
Expand Down Expand Up @@ -249,7 +248,6 @@ dependencies = [
"anyhow",
"flate2",
"hex 0.4.2",
"num_cpus",
"rayon",
"serde",
"serde_json",
Expand Down Expand Up @@ -4241,7 +4239,6 @@ name = "rustc_session"
version = "0.0.0"
dependencies = [
"getopts",
"num_cpus",
"rustc_ast",
"rustc_data_structures",
"rustc_errors",
Expand Down
2 changes: 1 addition & 1 deletion RELEASES.md
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,7 @@ Version 1.52.1 (2021-05-10)
This release disables incremental compilation, unless the user has explicitly
opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable.

This is due to the widespread, and frequently occuring, breakage encountered by
This is due to the widespread, and frequently occurring, breakage encountered by
Rust users due to newly enabled incremental verification in 1.52.0. Notably,
Rust users **should** upgrade to 1.52.0 or 1.52.1: the bugs that are detected by
newly added incremental verification are still present in past stable versions,
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_gcc/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
let val_type = value.get_type();
match (type_is_pointer(val_type), type_is_pointer(dest_ty)) {
(false, true) => {
// NOTE: Projecting a field of a pointer type will attemp a cast from a signed char to
// NOTE: Projecting a field of a pointer type will attempt a cast from a signed char to
// a pointer, which is not supported by gccjit.
return self.cx.context.new_cast(None, self.inttoptr(value, val_type.make_pointer()), dest_ty);
},
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_codegen_llvm/src/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -561,8 +561,7 @@ impl<'ll, 'tcx> FnAbiLlvmExt<'ll, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
if self.conv == Conv::CCmseNonSecureCall {
// This will probably get ignored on all targets but those supporting the TrustZone-M
// extension (thumbv8m targets).
let cmse_nonsecure_call =
llvm::CreateAttrString(bx.cx.llcx, cstr::cstr!("cmse_nonsecure_call"));
let cmse_nonsecure_call = llvm::CreateAttrString(bx.cx.llcx, "cmse_nonsecure_call");
attributes::apply_to_callsite(
callsite,
llvm::AttributePlace::Function,
Expand Down
52 changes: 23 additions & 29 deletions compiler/rustc_codegen_llvm/src/attributes.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
//! Set and unset common attributes on LLVM values.

use std::ffi::CString;

use cstr::cstr;
use rustc_codegen_ssa::traits::*;
use rustc_data_structures::small_c_str::SmallCStr;
use rustc_hir::def_id::DefId;
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
use rustc_middle::ty::{self, TyCtxt};
Expand Down Expand Up @@ -103,11 +99,11 @@ pub fn frame_pointer_type_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attr
fp = FramePointer::Always;
}
let attr_value = match fp {
FramePointer::Always => cstr!("all"),
FramePointer::NonLeaf => cstr!("non-leaf"),
FramePointer::Always => "all",
FramePointer::NonLeaf => "non-leaf",
FramePointer::MayOmit => return None,
};
Some(llvm::CreateAttrStringValue(cx.llcx, cstr!("frame-pointer"), attr_value))
Some(llvm::CreateAttrStringValue(cx.llcx, "frame-pointer", attr_value))
}

/// Tell LLVM what instrument function to insert.
Expand All @@ -119,11 +115,11 @@ fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu

// The function name varies on platforms.
// See test/CodeGen/mcount.c in clang.
let mcount_name = CString::new(cx.sess().target.mcount.as_str().as_bytes()).unwrap();
let mcount_name = cx.sess().target.mcount.as_str();

Some(llvm::CreateAttrStringValue(
cx.llcx,
cstr!("instrument-function-entry-inlined"),
"instrument-function-entry-inlined",
&mcount_name,
))
} else {
Expand Down Expand Up @@ -159,20 +155,20 @@ fn probestack_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
StackProbeType::None => return None,
// Request LLVM to generate the probes inline. If the given LLVM version does not support
// this, no probe is generated at all (even if the attribute is specified).
StackProbeType::Inline => cstr!("inline-asm"),
StackProbeType::Inline => "inline-asm",
// Flag our internal `__rust_probestack` function as the stack probe symbol.
// This is defined in the `compiler-builtins` crate for each architecture.
StackProbeType::Call => cstr!("__rust_probestack"),
StackProbeType::Call => "__rust_probestack",
// Pick from the two above based on the LLVM version.
StackProbeType::InlineOrCall { min_llvm_version_for_inline } => {
if llvm_util::get_version() < min_llvm_version_for_inline {
cstr!("__rust_probestack")
"__rust_probestack"
} else {
cstr!("inline-asm")
"inline-asm"
}
}
};
Some(llvm::CreateAttrStringValue(cx.llcx, cstr!("probe-stack"), attr_value))
Some(llvm::CreateAttrStringValue(cx.llcx, "probe-stack", attr_value))
}

fn stackprotector_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
Expand All @@ -187,15 +183,13 @@ fn stackprotector_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
}

pub fn target_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> &'ll Attribute {
let target_cpu = SmallCStr::new(llvm_util::target_cpu(cx.tcx.sess));
llvm::CreateAttrStringValue(cx.llcx, cstr!("target-cpu"), target_cpu.as_c_str())
let target_cpu = llvm_util::target_cpu(cx.tcx.sess);
llvm::CreateAttrStringValue(cx.llcx, "target-cpu", target_cpu)
}

pub fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
llvm_util::tune_cpu(cx.tcx.sess).map(|tune| {
let tune_cpu = SmallCStr::new(tune);
llvm::CreateAttrStringValue(cx.llcx, cstr!("tune-cpu"), tune_cpu.as_c_str())
})
llvm_util::tune_cpu(cx.tcx.sess)
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
}

/// Get the `NonLazyBind` LLVM attribute,
Expand Down Expand Up @@ -280,7 +274,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
}

if cx.sess().opts.debugging_opts.profile_sample_use.is_some() {
to_add.push(llvm::CreateAttrString(cx.llcx, cstr!("use-sample-profile")));
to_add.push(llvm::CreateAttrString(cx.llcx, "use-sample-profile"));
}

// FIXME: none of these three functions interact with source level attributes.
Expand Down Expand Up @@ -310,7 +304,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
attributes::apply_to_llfn(llfn, AttributePlace::ReturnValue, &[no_alias]);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::CMSE_NONSECURE_ENTRY) {
to_add.push(llvm::CreateAttrString(cx.llcx, cstr!("cmse_nonsecure_entry")));
to_add.push(llvm::CreateAttrString(cx.llcx, "cmse_nonsecure_entry"));
}
if let Some(align) = codegen_fn_attrs.alignment {
llvm::set_alignment(llfn, align as usize);
Expand Down Expand Up @@ -363,12 +357,12 @@ pub fn from_fn_attrs<'ll, 'tcx>(
// If this function is an import from the environment but the wasm
// import has a specific module/name, apply them here.
if let Some(module) = wasm_import_module(cx.tcx, instance.def_id()) {
to_add.push(llvm::CreateAttrStringValue(cx.llcx, cstr!("wasm-import-module"), &module));
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-module", &module));

let name =
codegen_fn_attrs.link_name.unwrap_or_else(|| cx.tcx.item_name(instance.def_id()));
let name = CString::new(name.as_str()).unwrap();
to_add.push(llvm::CreateAttrStringValue(cx.llcx, cstr!("wasm-import-name"), &name));
let name = name.as_str();
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "wasm-import-name", name));
}

// The `"wasm"` abi on wasm targets automatically enables the
Expand All @@ -388,13 +382,13 @@ pub fn from_fn_attrs<'ll, 'tcx>(
let val = global_features
.chain(function_features.iter().map(|s| &s[..]))
.intersperse(",")
.collect::<SmallCStr>();
to_add.push(llvm::CreateAttrStringValue(cx.llcx, cstr!("target-features"), &val));
.collect::<String>();
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &val));
}

attributes::apply_to_llfn(llfn, Function, &to_add);
}

fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option<CString> {
tcx.wasm_import_module_map(id.krate).get(&id).map(|s| CString::new(&s[..]).unwrap())
fn wasm_import_module(tcx: TyCtxt<'_>, id: DefId) -> Option<&String> {
tcx.wasm_import_module_map(id.krate).get(&id)
}
5 changes: 3 additions & 2 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1175,11 +1175,12 @@ extern "C" {

// Operations on attributes
pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
pub fn LLVMRustCreateAttrString(C: &Context, Name: *const c_char) -> &Attribute;
pub fn LLVMRustCreateAttrStringValue(
pub fn LLVMCreateStringAttribute(
C: &Context,
Name: *const c_char,
NameLen: c_uint,
Value: *const c_char,
ValueLen: c_uint,
) -> &Attribute;
pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
Expand Down
24 changes: 20 additions & 4 deletions compiler/rustc_codegen_llvm/src/llvm/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,28 @@ pub fn AddCallSiteAttributes<'ll>(
}
}

pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &CStr, value: &CStr) -> &'ll Attribute {
unsafe { LLVMRustCreateAttrStringValue(llcx, attr.as_ptr(), value.as_ptr()) }
pub fn CreateAttrStringValue<'ll>(llcx: &'ll Context, attr: &str, value: &str) -> &'ll Attribute {
unsafe {
LLVMCreateStringAttribute(
llcx,
attr.as_ptr().cast(),
attr.len().try_into().unwrap(),
value.as_ptr().cast(),
value.len().try_into().unwrap(),
)
}
}

pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &CStr) -> &'ll Attribute {
unsafe { LLVMRustCreateAttrStringValue(llcx, attr.as_ptr(), std::ptr::null()) }
pub fn CreateAttrString<'ll>(llcx: &'ll Context, attr: &str) -> &'ll Attribute {
unsafe {
LLVMCreateStringAttribute(
llcx,
attr.as_ptr().cast(),
attr.len().try_into().unwrap(),
std::ptr::null(),
0,
)
}
}

pub fn CreateAlignmentAttr(llcx: &Context, bytes: u64) -> &Attribute {
Expand Down
10 changes: 5 additions & 5 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,12 +369,12 @@ pub fn target_cpu(sess: &Session) -> &str {
/// The list of LLVM features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
/// `--target` and similar).
pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<String> {
// Features that come earlier are overriden by conflicting features later in the string.
// Features that come earlier are overridden by conflicting features later in the string.
// Typically we'll want more explicit settings to override the implicit ones, so:
//
// * Features from -Ctarget-cpu=*; are overriden by [^1]
// * Features implied by --target; are overriden by
// * Features from -Ctarget-feature; are overriden by
// * Features from -Ctarget-cpu=*; are overridden by [^1]
// * Features implied by --target; are overridden by
// * Features from -Ctarget-feature; are overridden by
// * function specific features.
//
// [^1]: target-cpu=native is handled here, other target-cpu values are handled implicitly
Expand All @@ -383,7 +383,7 @@ pub(crate) fn global_llvm_features(sess: &Session, diagnostics: bool) -> Vec<Str
// FIXME(nagisa): it isn't clear what's the best interaction between features implied by
// `-Ctarget-cpu` and `--target` are. On one hand, you'd expect CLI arguments to always
// override anything that's implicit, so e.g. when there's no `--target` flag, features implied
// the host target are overriden by `-Ctarget-cpu=*`. On the other hand, what about when both
// the host target are overridden by `-Ctarget-cpu=*`. On the other hand, what about when both
// `--target` and `-Ctarget-cpu=*` are specified? Both then imply some target features and both
// flags are specified by the user on the CLI. It isn't as clear-cut which order of precedence
// should be taken in cases like these.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/debuginfo/type_names.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Type Names for Debug Info.

// Notes on targetting MSVC:
// Notes on targeting MSVC:
// In general, MSVC's debugger attempts to parse all arguments as C++ expressions,
// even if the argument is explicitly a symbol name.
// As such, there are many things that cause parsing issues:
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/src/target_features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const ARM_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
// #[target_feature].
("thumb-mode", Some(sym::arm_target_feature)),
("thumb2", Some(sym::arm_target_feature)),
("d32", Some(sym::arm_target_feature)),
];

const AARCH64_ALLOWED_FEATURES: &[(&str, Option<Symbol>)] = &[
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_const_eval/src/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -535,7 +535,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
let val =
self.subst_from_current_frame_and_normalize_erasing_regions(constant.literal)?;
// This can still fail:
// * During ConstProp, with `TooGeneric` or since the `requried_consts` were not all
// * During ConstProp, with `TooGeneric` or since the `required_consts` were not all
// checked yet.
// * During CTFE, since promoteds in `const`/`static` initializer bodies can fail.

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_driver/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,7 @@ pub fn report_ice(info: &panic::PanicInfo<'_>, bug_report_url: &str) {
///
/// A custom rustc driver can skip calling this to set up a custom ICE hook.
pub fn install_ice_hook() {
// If the user has not explicitly overriden "RUST_BACKTRACE", then produce
// If the user has not explicitly overridden "RUST_BACKTRACE", then produce
// full backtraces. When a compiler ICE happens, we want to gather
// as much information as possible to present in the issue opened
// by the user. Compiler developers and other rustc users can
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0772.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ trait object's internal data to be accessed safely from any trait methods. This
rule also goes for any lifetime any struct made into a trait object may have.

In the implementation for `dyn Person`, the `'2` lifetime representing the
internal data was ommitted, meaning that the compiler inferred the lifetime
internal data was omitted, meaning that the compiler inferred the lifetime
`'static`. As a result, the implementation's `is_cool` is inferred by the
compiler to look like this:

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_expand/src/expand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,7 +1841,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
self.flat_map_node(node)
}

fn flat_map_stmt(&mut self, mut node: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
fn flat_map_stmt(&mut self, node: ast::Stmt) -> SmallVec<[ast::Stmt; 1]> {
// FIXME: invocations in semicolon-less expressions positions are expanded as expressions,
// changing that requires some compatibility measures.
if node.is_expr() {
Expand All @@ -1863,7 +1863,7 @@ impl<'a, 'b> MutVisitor for InvocationCollector<'a, 'b> {
self.cx.current_expansion.is_trailing_mac = false;
res
}
_ => assign_id!(self, &mut node.id, || noop_flat_map_stmt(node, self)),
_ => noop_flat_map_stmt(node, self),
};
}

Expand Down
Loading