Skip to content

Commit b9a8a4a

Browse files
committed
Merge remote-tracking branch 'origin/master' into optimize-upper-lower-auto-vectorization
2 parents 60a13dd + 702987f commit b9a8a4a

File tree

2,316 files changed

+26318
-19665
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,316 files changed

+26318
-19665
lines changed

Cargo.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -4630,7 +4630,7 @@ dependencies = [
46304630

46314631
[[package]]
46324632
name = "rustfmt-nightly"
4633-
version = "1.7.1"
4633+
version = "1.8.0"
46344634
dependencies = [
46354635
"annotate-snippets 0.9.2",
46364636
"anyhow",

compiler/rustc_abi/src/layout.rs

+5-10
Original file line numberDiff line numberDiff line change
@@ -527,15 +527,10 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
527527
let count =
528528
(niche_variants.end().index() as u128 - niche_variants.start().index() as u128) + 1;
529529

530-
// Find the field with the largest niche
531-
let (field_index, niche, (niche_start, niche_scalar)) = variants[largest_variant_index]
532-
.iter()
533-
.enumerate()
534-
.filter_map(|(j, field)| Some((j, field.largest_niche?)))
535-
.max_by_key(|(_, niche)| niche.available(dl))
536-
.and_then(|(j, niche)| Some((j, niche, niche.reserve(dl, count)?)))?;
537-
let niche_offset =
538-
niche.offset + variant_layouts[largest_variant_index].fields.offset(field_index);
530+
// Use the largest niche in the largest variant.
531+
let niche = variant_layouts[largest_variant_index].largest_niche?;
532+
let (niche_start, niche_scalar) = niche.reserve(dl, count)?;
533+
let niche_offset = niche.offset;
539534
let niche_size = niche.value.size(dl);
540535
let size = variant_layouts[largest_variant_index].size.align_to(align.abi);
541536

@@ -1004,8 +999,8 @@ impl<Cx: HasDataLayout> LayoutCalculator<Cx> {
1004999
if repr.can_randomize_type_layout() && cfg!(feature = "randomize") {
10051000
#[cfg(feature = "randomize")]
10061001
{
1007-
use rand::seq::SliceRandom;
10081002
use rand::SeedableRng;
1003+
use rand::seq::SliceRandom;
10091004
// `ReprOptions.field_shuffle_seed` is a deterministic seed we can use to randomize field
10101005
// ordering.
10111006
let mut rng =

compiler/rustc_abi/src/lib.rs

+30-13
Original file line numberDiff line numberDiff line change
@@ -337,23 +337,21 @@ impl TargetDataLayout {
337337
Ok(dl)
338338
}
339339

340-
/// Returns exclusive upper bound on object size.
340+
/// Returns **exclusive** upper bound on object size in bytes.
341341
///
342342
/// The theoretical maximum object size is defined as the maximum positive `isize` value.
343343
/// This ensures that the `offset` semantics remain well-defined by allowing it to correctly
344344
/// index every address within an object along with one byte past the end, along with allowing
345345
/// `isize` to store the difference between any two pointers into an object.
346346
///
347-
/// The upper bound on 64-bit currently needs to be lower because LLVM uses a 64-bit integer
348-
/// to represent object size in bits. It would need to be 1 << 61 to account for this, but is
349-
/// currently conservatively bounded to 1 << 47 as that is enough to cover the current usable
350-
/// address space on 64-bit ARMv8 and x86_64.
347+
/// LLVM uses a 64-bit integer to represent object size in *bits*, but we care only for bytes,
348+
/// so we adopt such a more-constrained size bound due to its technical limitations.
351349
#[inline]
352350
pub fn obj_size_bound(&self) -> u64 {
353351
match self.pointer_size.bits() {
354352
16 => 1 << 15,
355353
32 => 1 << 31,
356-
64 => 1 << 47,
354+
64 => 1 << 61,
357355
bits => panic!("obj_size_bound: unknown pointer bit size {bits}"),
358356
}
359357
}
@@ -833,6 +831,28 @@ pub enum Integer {
833831
}
834832

835833
impl Integer {
834+
pub fn int_ty_str(self) -> &'static str {
835+
use Integer::*;
836+
match self {
837+
I8 => "i8",
838+
I16 => "i16",
839+
I32 => "i32",
840+
I64 => "i64",
841+
I128 => "i128",
842+
}
843+
}
844+
845+
pub fn uint_ty_str(self) -> &'static str {
846+
use Integer::*;
847+
match self {
848+
I8 => "u8",
849+
I16 => "u16",
850+
I32 => "u32",
851+
I64 => "u64",
852+
I128 => "u128",
853+
}
854+
}
855+
836856
#[inline]
837857
pub fn size(self) -> Size {
838858
use Integer::*;
@@ -1118,13 +1138,10 @@ impl Scalar {
11181138
#[inline]
11191139
pub fn is_bool(&self) -> bool {
11201140
use Integer::*;
1121-
matches!(
1122-
self,
1123-
Scalar::Initialized {
1124-
value: Primitive::Int(I8, false),
1125-
valid_range: WrappingRange { start: 0, end: 1 }
1126-
}
1127-
)
1141+
matches!(self, Scalar::Initialized {
1142+
value: Primitive::Int(I8, false),
1143+
valid_range: WrappingRange { start: 0, end: 1 }
1144+
})
11281145
}
11291146

11301147
/// Get the primitive representation of this type, ignoring the valid range and whether the

compiler/rustc_ast/src/ast.rs

+13-12
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,19 @@
2121
use std::borrow::Cow;
2222
use std::{cmp, fmt, mem};
2323

24+
pub use GenericArgs::*;
25+
pub use UnsafeSource::*;
2426
pub use rustc_ast_ir::{Movability, Mutability};
2527
use rustc_data_structures::packed::Pu128;
2628
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2729
use rustc_data_structures::stack::ensure_sufficient_stack;
2830
use rustc_data_structures::sync::Lrc;
2931
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
30-
use rustc_span::source_map::{respan, Spanned};
31-
use rustc_span::symbol::{kw, sym, Ident, Symbol};
3232
pub use rustc_span::AttrId;
33-
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
34-
use thin_vec::{thin_vec, ThinVec};
35-
pub use GenericArgs::*;
36-
pub use UnsafeSource::*;
33+
use rustc_span::source_map::{Spanned, respan};
34+
use rustc_span::symbol::{Ident, Symbol, kw, sym};
35+
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
36+
use thin_vec::{ThinVec, thin_vec};
3737

3838
pub use crate::format::*;
3939
use crate::ptr::P;
@@ -288,7 +288,7 @@ impl ParenthesizedArgs {
288288
}
289289
}
290290

291-
pub use crate::node_id::{NodeId, CRATE_NODE_ID, DUMMY_NODE_ID};
291+
pub use crate::node_id::{CRATE_NODE_ID, DUMMY_NODE_ID, NodeId};
292292

293293
/// Modifiers on a trait bound like `~const`, `?` and `!`.
294294
#[derive(Copy, Clone, PartialEq, Eq, Encodable, Decodable, Debug)]
@@ -1187,8 +1187,8 @@ impl Expr {
11871187
/// `min_const_generics` as more complex expressions are not supported.
11881188
///
11891189
/// Does not ensure that the path resolves to a const param, the caller should check this.
1190-
pub fn is_potential_trivial_const_arg(&self) -> bool {
1191-
let this = self.maybe_unwrap_block();
1190+
pub fn is_potential_trivial_const_arg(&self, strip_identity_block: bool) -> bool {
1191+
let this = if strip_identity_block { self.maybe_unwrap_block().1 } else { self };
11921192

11931193
if let ExprKind::Path(None, path) = &this.kind
11941194
&& path.is_potential_trivial_const_arg()
@@ -1199,14 +1199,15 @@ impl Expr {
11991199
}
12001200
}
12011201

1202-
pub fn maybe_unwrap_block(&self) -> &Expr {
1202+
/// Returns an expression with (when possible) *one* outter brace removed
1203+
pub fn maybe_unwrap_block(&self) -> (bool, &Expr) {
12031204
if let ExprKind::Block(block, None) = &self.kind
12041205
&& let [stmt] = block.stmts.as_slice()
12051206
&& let StmtKind::Expr(expr) = &stmt.kind
12061207
{
1207-
expr
1208+
(true, expr)
12081209
} else {
1209-
self
1210+
(false, self)
12101211
}
12111212
}
12121213

compiler/rustc_ast/src/attr/mod.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ use std::iter;
44
use std::sync::atomic::{AtomicU32, Ordering};
55

66
use rustc_index::bit_set::GrowableBitSet;
7-
use rustc_span::symbol::{sym, Ident, Symbol};
87
use rustc_span::Span;
9-
use smallvec::{smallvec, SmallVec};
10-
use thin_vec::{thin_vec, ThinVec};
8+
use rustc_span::symbol::{Ident, Symbol, sym};
9+
use smallvec::{SmallVec, smallvec};
10+
use thin_vec::{ThinVec, thin_vec};
1111

1212
use crate::ast::{
13-
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DelimArgs,
14-
Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem, NormalAttr, Path,
15-
PathSegment, Safety, DUMMY_NODE_ID,
13+
AttrArgs, AttrArgsEq, AttrId, AttrItem, AttrKind, AttrStyle, AttrVec, Attribute, DUMMY_NODE_ID,
14+
DelimArgs, Expr, ExprKind, LitKind, MetaItem, MetaItemKind, MetaItemLit, NestedMetaItem,
15+
NormalAttr, Path, PathSegment, Safety,
1616
};
1717
use crate::ptr::P;
1818
use crate::token::{self, CommentKind, Delimiter, Token};

compiler/rustc_ast/src/entry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use rustc_span::symbol::sym;
21
use rustc_span::Symbol;
2+
use rustc_span::symbol::sym;
33

4-
use crate::{attr, Attribute};
4+
use crate::{Attribute, attr};
55

66
#[derive(Debug)]
77
pub enum EntryPointType {

compiler/rustc_ast/src/expand/allocator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use rustc_macros::HashStable_Generic;
2-
use rustc_span::symbol::{sym, Symbol};
2+
use rustc_span::symbol::{Symbol, sym};
33

44
#[derive(Clone, Debug, Copy, Eq, PartialEq, HashStable_Generic)]
55
pub enum AllocatorKind {

compiler/rustc_ast/src/format.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
use rustc_data_structures::fx::FxHashMap;
22
use rustc_macros::{Decodable, Encodable};
3-
use rustc_span::symbol::{Ident, Symbol};
43
use rustc_span::Span;
4+
use rustc_span::symbol::{Ident, Symbol};
55

6-
use crate::ptr::P;
76
use crate::Expr;
7+
use crate::ptr::P;
88

99
// Definitions:
1010
//

compiler/rustc_ast/src/mut_visit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ use std::panic;
1313
use rustc_data_structures::flat_map_in_place::FlatMapInPlace;
1414
use rustc_data_structures::stack::ensure_sufficient_stack;
1515
use rustc_data_structures::sync::Lrc;
16+
use rustc_span::Span;
1617
use rustc_span::source_map::Spanned;
1718
use rustc_span::symbol::Ident;
18-
use rustc_span::Span;
19-
use smallvec::{smallvec, Array, SmallVec};
19+
use smallvec::{Array, SmallVec, smallvec};
2020
use thin_vec::ThinVec;
2121

2222
use crate::ast::*;

compiler/rustc_ast/src/token.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
use std::borrow::Cow;
22
use std::fmt;
33

4+
pub use BinOpToken::*;
5+
pub use LitKind::*;
6+
pub use Nonterminal::*;
7+
pub use NtExprKind::*;
8+
pub use NtPatKind::*;
9+
pub use TokenKind::*;
410
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
511
use rustc_data_structures::sync::Lrc;
612
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
713
use rustc_span::edition::Edition;
8-
use rustc_span::symbol::{kw, sym};
914
#[allow(clippy::useless_attribute)] // FIXME: following use of `hidden_glob_reexports` incorrectly triggers `useless_attribute` lint.
1015
#[allow(hidden_glob_reexports)]
1116
use rustc_span::symbol::{Ident, Symbol};
12-
use rustc_span::{ErrorGuaranteed, Span, DUMMY_SP};
13-
pub use BinOpToken::*;
14-
pub use LitKind::*;
15-
pub use Nonterminal::*;
16-
pub use NtExprKind::*;
17-
pub use NtPatKind::*;
18-
pub use TokenKind::*;
17+
use rustc_span::symbol::{kw, sym};
18+
use rustc_span::{DUMMY_SP, ErrorGuaranteed, Span};
1919

2020
use crate::ast;
2121
use crate::ptr::P;

compiler/rustc_ast/src/tokenstream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
2020
use rustc_data_structures::sync::{self, Lrc};
2121
use rustc_macros::{Decodable, Encodable, HashStable_Generic};
2222
use rustc_serialize::{Decodable, Encodable};
23-
use rustc_span::{sym, Span, SpanDecoder, SpanEncoder, Symbol, DUMMY_SP};
23+
use rustc_span::{DUMMY_SP, Span, SpanDecoder, SpanEncoder, Symbol, sym};
2424

2525
use crate::ast::{AttrStyle, StmtKind};
2626
use crate::ast_traits::{HasAttrs, HasTokens};

compiler/rustc_ast/src/util/literal.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
use std::{ascii, fmt, str};
44

55
use rustc_lexer::unescape::{
6-
byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode, MixedUnit, Mode,
6+
MixedUnit, Mode, byte_from_char, unescape_byte, unescape_char, unescape_mixed, unescape_unicode,
77
};
8-
use rustc_span::symbol::{kw, sym, Symbol};
98
use rustc_span::Span;
9+
use rustc_span::symbol::{Symbol, kw, sym};
1010
use tracing::debug;
1111

1212
use crate::ast::{self, LitKind, MetaItemLit, StrStyle};

compiler/rustc_ast/src/visit.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
1616
pub use rustc_ast_ir::visit::VisitorResult;
1717
pub use rustc_ast_ir::{try_visit, visit_opt, walk_list, walk_visitable_list};
18-
use rustc_span::symbol::Ident;
1918
use rustc_span::Span;
19+
use rustc_span::symbol::Ident;
2020

2121
use crate::ast::*;
2222
use crate::ptr::P;

compiler/rustc_ast_lowering/src/asm.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ use rustc_hir as hir;
88
use rustc_hir::def::{DefKind, Res};
99
use rustc_session::parse::feature_err;
1010
use rustc_span::symbol::kw;
11-
use rustc_span::{sym, Span};
11+
use rustc_span::{Span, sym};
1212
use rustc_target::asm;
1313

14+
use super::LoweringContext;
1415
use super::errors::{
1516
AbiSpecifiedMultipleTimes, AttSyntaxOnlyX86, ClobberAbiNotSupported,
1617
InlineAsmUnsupportedTarget, InvalidAbiClobberAbi, InvalidAsmTemplateModifierConst,
1718
InvalidAsmTemplateModifierLabel, InvalidAsmTemplateModifierRegClass,
1819
InvalidAsmTemplateModifierRegClassSub, InvalidAsmTemplateModifierSym, InvalidRegister,
1920
InvalidRegisterClass, RegisterClassOnlyClobber, RegisterConflict,
2021
};
21-
use super::LoweringContext;
2222
use crate::{
23-
fluent_generated as fluent, ImplTraitContext, ImplTraitPosition, ParamMode,
24-
ResolverAstLoweringExt,
23+
AllowReturnTypeNotation, ImplTraitContext, ImplTraitPosition, ParamMode,
24+
ResolverAstLoweringExt, fluent_generated as fluent,
2525
};
2626

2727
impl<'a, 'hir> LoweringContext<'a, 'hir> {
@@ -201,6 +201,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
201201
&sym.qself,
202202
&sym.path,
203203
ParamMode::Optional,
204+
AllowReturnTypeNotation::No,
204205
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
205206
None,
206207
);
@@ -220,7 +221,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
220221
let parent_def_id = self.current_def_id_parent;
221222
let node_id = self.next_node_id();
222223
// HACK(min_generic_const_args): see lower_anon_const
223-
if !expr.is_potential_trivial_const_arg() {
224+
if !expr.is_potential_trivial_const_arg(true) {
224225
self.create_def(
225226
parent_def_id,
226227
node_id,

compiler/rustc_ast_lowering/src/delegation.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,13 @@ use rustc_errors::ErrorGuaranteed;
4646
use rustc_hir::def_id::DefId;
4747
use rustc_middle::span_bug;
4848
use rustc_middle::ty::{Asyncness, ResolverAstLowering};
49-
use rustc_span::symbol::Ident;
5049
use rustc_span::Span;
50+
use rustc_span::symbol::Ident;
5151
use rustc_target::spec::abi;
5252
use {rustc_ast as ast, rustc_hir as hir};
5353

5454
use super::{GenericArgsMode, ImplTraitContext, LoweringContext, ParamMode};
55-
use crate::{ImplTraitPosition, ResolverAstLoweringExt};
55+
use crate::{AllowReturnTypeNotation, ImplTraitPosition, ResolverAstLoweringExt};
5656

5757
pub(crate) struct DelegationResults<'hir> {
5858
pub body_id: hir::BodyId,
@@ -340,6 +340,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
340340
&delegation.qself,
341341
&delegation.path,
342342
ParamMode::Optional,
343+
AllowReturnTypeNotation::No,
343344
ImplTraitContext::Disallowed(ImplTraitPosition::Path),
344345
None,
345346
);

0 commit comments

Comments
 (0)