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 #127125

Closed
wants to merge 28 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
e9ea578
Move vcall_visibility_metadata optimization hint out of a debuginfo g…
bjorn3 Mar 30, 2024
7f44532
Remove PrintBackendInfo trait
bjorn3 Mar 30, 2024
98e8601
Remove const_bitcast from ConstMethods
bjorn3 Mar 30, 2024
e32eb4c
Dedup some intrinsic handling code for caller_location
bjorn3 Mar 30, 2024
22b3243
Move all intrinsic handling code in codegen_call_terminators together
bjorn3 Mar 30, 2024
aacdce3
Remove check_overflow method from MiscMethods
bjorn3 Mar 30, 2024
887f57f
Remove type_i1 and type_struct from cg_ssa
bjorn3 Mar 30, 2024
84f45bb
Fix doc comment
bjorn3 Mar 30, 2024
8a87f02
Improve error message in tidy
Kobzol Jun 25, 2024
151986f
Implement `x perf` as a separate tool
Kobzol Jun 27, 2024
a62cbda
Add feature diagnostic for unsafe_extern_blocks
spastorino Jun 29, 2024
50edb32
Fix a error suggestion for E0121 when using placeholder _ as return t…
surechen Jun 29, 2024
4442fd7
Add a run-make test that LLD is not being used by default on the x64 …
Kobzol Jun 28, 2024
9c0ce05
Show `used attribute`'s kind for user when find it isn't applied to a…
surechen Jun 29, 2024
8dc36c1
fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer
linyihai Jun 29, 2024
c54a2a5
Make mtime of reproducible tarball dependent on git commit
Kobzol Jun 27, 2024
f6f21a8
Review changes
Kobzol Jun 29, 2024
6a2638e
Autolabel `rustc-perf-wrapper` changes with t-bootstrap label
Kobzol Jun 29, 2024
15d5dac
Avoid suggesting to add unsafe when the extern block is already unsafe
spastorino Jun 29, 2024
31eed5d
Rollup merge of #123237 - bjorn3:debuginfo_refactor, r=compiler-errors
matthiaskrgr Jun 29, 2024
3f83e16
Rollup merge of #126960 - Kobzol:tidy-venv-message, r=tgross35
matthiaskrgr Jun 29, 2024
ffc429d
Rollup merge of #127002 - Kobzol:bootstrap-perf-tool, r=onur-ozkan
matthiaskrgr Jun 29, 2024
841d18d
Rollup merge of #127050 - Kobzol:reproducibility-git, r=onur-ozkan
matthiaskrgr Jun 29, 2024
bbd3a78
Rollup merge of #127081 - Kobzol:lld-test, r=onur-ozkan
matthiaskrgr Jun 29, 2024
b3b25bd
Rollup merge of #127106 - spastorino:improve-unsafe-extern-blocks-dia…
matthiaskrgr Jun 29, 2024
059e506
Rollup merge of #127110 - surechen:fix_125488_06, r=compiler-errors
matthiaskrgr Jun 29, 2024
5daa616
Rollup merge of #127114 - linyihai:issue-126863, r=Nadrieril
matthiaskrgr Jun 29, 2024
fb181b2
Rollup merge of #127118 - surechen:fix_126789, r=jieyouxu
matthiaskrgr Jun 29, 2024
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
7 changes: 7 additions & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3460,6 +3460,13 @@ dependencies = [
"stable_mir",
]

[[package]]
name = "rustc-perf-wrapper"
version = "0.1.0"
dependencies = [
"clap",
]

[[package]]
name = "rustc-rayon"
version = "0.5.0"
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ members = [
"src/tools/rustdoc-gui-test",
"src/tools/opt-dist",
"src/tools/coverage-dump",
"src/tools/rustc-perf-wrapper",
]

exclude = [
Expand Down
29 changes: 21 additions & 8 deletions compiler/rustc_ast_passes/src/ast_validation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,13 +469,18 @@ impl<'a> AstValidator<'a> {
fn check_item_safety(&self, span: Span, safety: Safety) {
match self.extern_mod_safety {
Some(extern_safety) => {
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_))
&& (extern_safety == Safety::Default || !self.features.unsafe_extern_blocks)
{
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: self.current_extern_span().shrink_to_lo(),
});
if matches!(safety, Safety::Unsafe(_) | Safety::Safe(_)) {
if extern_safety == Safety::Default {
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: Some(self.current_extern_span().shrink_to_lo()),
});
} else if !self.features.unsafe_extern_blocks {
self.dcx().emit_err(errors::InvalidSafetyOnExtern {
item_span: span,
block: None,
});
}
}
}
None => {
Expand Down Expand Up @@ -1098,7 +1103,15 @@ impl<'a> Visitor<'a> for AstValidator<'a> {
}
}
} else if let &Safety::Unsafe(span) = safety {
this.dcx().emit_err(errors::UnsafeItem { span, kind: "extern block" });
let mut diag = this
.dcx()
.create_err(errors::UnsafeItem { span, kind: "extern block" });
rustc_session::parse::add_feature_diagnostics(
&mut diag,
self.session,
sym::unsafe_extern_blocks,
);
diag.emit();
}

if abi.is_none() {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast_passes/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ pub struct InvalidSafetyOnExtern {
#[primary_span]
pub item_span: Span,
#[suggestion(code = "unsafe ", applicability = "machine-applicable", style = "verbose")]
pub block: Span,
pub block: Option<Span>,
}

#[derive(Diagnostic)]
Expand Down
26 changes: 23 additions & 3 deletions compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,14 +1288,16 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
return false;
}
// Try to find predicates on *generic params* that would allow copying `ty`
let suggestion =
let mut suggestion =
if let Some(symbol) = tcx.hir().maybe_get_struct_pattern_shorthand_field(expr) {
format!(": {symbol}.clone()")
} else {
".clone()".to_owned()
};
let mut sugg = Vec::with_capacity(2);
let mut inner_expr = expr;
let mut is_raw_ptr = false;
let typeck_result = self.infcx.tcx.typeck(self.mir_def_id());
// Remove uses of `&` and `*` when suggesting `.clone()`.
while let hir::ExprKind::AddrOf(.., inner) | hir::ExprKind::Unary(hir::UnOp::Deref, inner) =
&inner_expr.kind
Expand All @@ -1306,14 +1308,32 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
return false;
}
inner_expr = inner;
if let Some(inner_type) = typeck_result.node_type_opt(inner.hir_id) {
if matches!(inner_type.kind(), ty::RawPtr(..)) {
is_raw_ptr = true;
break;
}
}
}
if inner_expr.span.lo() != expr.span.lo() {
// Cloning the raw pointer doesn't make sense in some cases and would cause a type mismatch error. (see #126863)
if inner_expr.span.lo() != expr.span.lo() && !is_raw_ptr {
// Remove "(*" or "(&"
sugg.push((expr.span.with_hi(inner_expr.span.lo()), String::new()));
}
// Check whether `expr` is surrounded by parentheses or not.
let span = if inner_expr.span.hi() != expr.span.hi() {
// Account for `(*x)` to suggest `x.clone()`.
expr.span.with_lo(inner_expr.span.hi())
if is_raw_ptr {
expr.span.shrink_to_hi()
} else {
// Remove the close parenthesis ")"
expr.span.with_lo(inner_expr.span.hi())
}
} else {
if is_raw_ptr {
sugg.push((expr.span.shrink_to_lo(), "(".to_string()));
suggestion = ").clone()".to_string();
}
expr.span.shrink_to_hi()
};
sugg.push((span, suggestion));
Expand Down
27 changes: 21 additions & 6 deletions compiler/rustc_borrowck/src/diagnostics/move_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,12 +639,27 @@ impl<'tcx> MirBorrowckCtxt<'_, '_, '_, 'tcx> {
fn add_borrow_suggestions(&self, err: &mut Diag<'_>, span: Span) {
match self.infcx.tcx.sess.source_map().span_to_snippet(span) {
Ok(snippet) if snippet.starts_with('*') => {
err.span_suggestion_verbose(
span.with_hi(span.lo() + BytePos(1)),
"consider removing the dereference here",
String::new(),
Applicability::MaybeIncorrect,
);
let sp = span.with_lo(span.lo() + BytePos(1));
let inner = self.find_expr(sp);
let mut is_raw_ptr = false;
if let Some(inner) = inner {
let typck_result = self.infcx.tcx.typeck(self.mir_def_id());
if let Some(inner_type) = typck_result.node_type_opt(inner.hir_id) {
if matches!(inner_type.kind(), ty::RawPtr(..)) {
is_raw_ptr = true;
}
}
}
// If the `inner` is a raw pointer, do not suggest removing the "*", see #126863
// FIXME: need to check whether the assigned object can be a raw pointer, see `tests/ui/borrowck/issue-20801.rs`.
if !is_raw_ptr {
err.span_suggestion_verbose(
span.with_hi(span.lo() + BytePos(1)),
"consider removing the dereference here",
String::new(),
Applicability::MaybeIncorrect,
);
}
}
_ => {
err.span_suggestion_verbose(
Expand Down
26 changes: 13 additions & 13 deletions compiler/rustc_codegen_gcc/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,19 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
global
// TODO(antoyo): set linkage.
}

pub fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
if value.get_type() == self.bool_type.make_pointer() {
if let Some(pointee) = typ.get_pointee() {
if pointee.dyncast_vector().is_some() {
panic!()
}
}
}
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
// SIMD builtins require a constant value.
self.bitcast_if_needed(value, typ)
}
}

pub fn bytes_in_context<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, bytes: &[u8]) -> RValue<'gcc> {
Expand Down Expand Up @@ -239,19 +252,6 @@ impl<'gcc, 'tcx> ConstMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
const_alloc_to_gcc(self, alloc)
}

fn const_bitcast(&self, value: RValue<'gcc>, typ: Type<'gcc>) -> RValue<'gcc> {
if value.get_type() == self.bool_type.make_pointer() {
if let Some(pointee) = typ.get_pointee() {
if pointee.dyncast_vector().is_some() {
panic!()
}
}
}
// NOTE: since bitcast makes a value non-constant, don't bitcast if not necessary as some
// SIMD builtins require a constant value.
self.bitcast_if_needed(value, typ)
}

fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
self.context
.new_array_access(None, base_addr, self.const_usize(offset.bytes()))
Expand Down
8 changes: 0 additions & 8 deletions compiler/rustc_codegen_gcc/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use crate::callee::get_fn;
use crate::common::SignType;

pub struct CodegenCx<'gcc, 'tcx> {
pub check_overflow: bool,
pub codegen_unit: &'tcx CodegenUnit<'tcx>,
pub context: &'gcc Context<'gcc>,

Expand Down Expand Up @@ -134,8 +133,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
tcx: TyCtxt<'tcx>,
supports_128bit_integers: bool,
) -> Self {
let check_overflow = tcx.sess.overflow_checks();

let create_type = |ctype, rust_type| {
let layout = tcx.layout_of(ParamEnv::reveal_all().and(rust_type)).unwrap();
let align = layout.align.abi.bytes();
Expand Down Expand Up @@ -271,7 +268,6 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
}

let mut cx = Self {
check_overflow,
codegen_unit,
context,
current_func: RefCell::new(None),
Expand Down Expand Up @@ -511,10 +507,6 @@ impl<'gcc, 'tcx> MiscMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
&self.tcx.sess
}

fn check_overflow(&self) -> bool {
self.check_overflow
}

fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
self.codegen_unit
}
Expand Down
50 changes: 25 additions & 25 deletions compiler/rustc_codegen_gcc/src/type_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,34 @@ impl<'gcc, 'tcx> CodegenCx<'gcc, 'tcx> {
ty::FloatTy::F128 => self.type_f128(),
}
}
}

impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn type_i1(&self) -> Type<'gcc> {
pub fn type_i1(&self) -> Type<'gcc> {
self.bool_type
}

pub fn type_struct(&self, fields: &[Type<'gcc>], packed: bool) -> Type<'gcc> {
let types = fields.to_vec();
if let Some(typ) = self.struct_types.borrow().get(fields) {
return *typ;
}
let fields: Vec<_> = fields
.iter()
.enumerate()
.map(|(index, field)| {
self.context.new_field(None, *field, format!("field{}_TODO", index))
})
.collect();
let typ = self.context.new_struct_type(None, "struct", &fields).as_type();
if packed {
#[cfg(feature = "master")]
typ.set_packed();
}
self.struct_types.borrow_mut().insert(types, typ);
typ
}
}

impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn type_i8(&self) -> Type<'gcc> {
self.i8_type
}
Expand Down Expand Up @@ -131,7 +152,7 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
fn type_f64(&self) -> Type<'gcc> {
self.double_type
}

fn type_f128(&self) -> Type<'gcc> {
unimplemented!("f16_f128")
}
Expand All @@ -140,27 +161,6 @@ impl<'gcc, 'tcx> BaseTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
self.context.new_function_pointer_type(None, return_type, params, false)
}

fn type_struct(&self, fields: &[Type<'gcc>], packed: bool) -> Type<'gcc> {
let types = fields.to_vec();
if let Some(typ) = self.struct_types.borrow().get(fields) {
return *typ;
}
let fields: Vec<_> = fields
.iter()
.enumerate()
.map(|(index, field)| {
self.context.new_field(None, *field, format!("field{}_TODO", index))
})
.collect();
let typ = self.context.new_struct_type(None, "struct", &fields).as_type();
if packed {
#[cfg(feature = "master")]
typ.set_packed();
}
self.struct_types.borrow_mut().insert(types, typ);
typ
}

fn type_kind(&self, typ: Type<'gcc>) -> TypeKind {
if self.is_int_type_or_bool(typ) {
TypeKind::Integer
Expand Down
4 changes: 0 additions & 4 deletions compiler/rustc_codegen_llvm/src/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -329,10 +329,6 @@ impl<'ll, 'tcx> ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> {
const_alloc_to_llvm(self, alloc, /*static*/ false)
}

fn const_bitcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value {
self.const_bitcast(val, ty)
}

fn const_ptr_byte_offset(&self, base_addr: Self::Value, offset: abi::Size) -> Self::Value {
unsafe {
llvm::LLVMConstInBoundsGEP2(
Expand Down
18 changes: 10 additions & 8 deletions compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use crate::back::write::to_llvm_code_model;
use crate::callee::get_fn;
use crate::coverageinfo;
use crate::debuginfo;
use crate::debuginfo::metadata::apply_vcall_visibility_metadata;
use crate::llvm;
use crate::llvm_util;
use crate::type_::Type;
Expand Down Expand Up @@ -43,7 +44,6 @@ use std::str;
/// All other LLVM data structures in the `CodegenCx` are tied to that `llvm::Context`.
pub struct CodegenCx<'ll, 'tcx> {
pub tcx: TyCtxt<'tcx>,
pub check_overflow: bool,
pub use_dll_storage_attrs: bool,
pub tls_model: llvm::ThreadLocalMode,

Expand Down Expand Up @@ -441,8 +441,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {
// start) and then strongly recommending static linkage on Windows!
let use_dll_storage_attrs = tcx.sess.target.is_like_windows;

let check_overflow = tcx.sess.overflow_checks();

let tls_model = to_llvm_tls_model(tcx.sess.tls_model());

let (llcx, llmod) = (&*llvm_module.llcx, llvm_module.llmod());
Expand All @@ -466,7 +464,6 @@ impl<'ll, 'tcx> CodegenCx<'ll, 'tcx> {

CodegenCx {
tcx,
check_overflow,
use_dll_storage_attrs,
tls_model,
llmod,
Expand Down Expand Up @@ -522,6 +519,15 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
&self.vtables
}

fn apply_vcall_visibility_metadata(
&self,
ty: Ty<'tcx>,
poly_trait_ref: Option<ty::PolyExistentialTraitRef<'tcx>>,
vtable: &'ll Value,
) {
apply_vcall_visibility_metadata(self, ty, poly_trait_ref, vtable);
}

fn get_fn(&self, instance: Instance<'tcx>) -> &'ll Value {
get_fn(self, instance)
}
Expand Down Expand Up @@ -596,10 +602,6 @@ impl<'ll, 'tcx> MiscMethods<'tcx> for CodegenCx<'ll, 'tcx> {
self.tcx.sess
}

fn check_overflow(&self) -> bool {
self.check_overflow
}

fn codegen_unit(&self) -> &'tcx CodegenUnit<'tcx> {
self.codegen_unit
}
Expand Down
Loading
Loading