Skip to content

Automated pull from upstream master #50

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 64 commits into from
Oct 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
8f9cd3d
Rework range splitting api
Nadrieril Oct 3, 2023
590edee
Rework slice splitting api
Nadrieril Oct 3, 2023
429770a
Splitting ensures subrange comparison is all we need
Nadrieril Oct 3, 2023
c1800ef
Replace SplitWildcard with a cleaner ConstructorSet abstraction
Nadrieril Oct 3, 2023
2f4cab4
Clarify handling of hidden variants
Nadrieril Oct 3, 2023
fda0301
Don't collect `seen` if not needed
Nadrieril Oct 3, 2023
edf6a2d
Clarify for review
Nadrieril Oct 4, 2023
c1b29b3
Fix handling slices of empty types
Nadrieril Oct 4, 2023
ae9cec5
Copy 1-element arrays as scalars, not vectors
scottmcm Oct 6, 2023
6b9ee90
Reuse determine_cgu_reuse from cg_ssa in cg_clif
bjorn3 Sep 16, 2023
3dfd9df
Remove an LTO dependent cgu_reuse_tracker.set_actual_reuse call
bjorn3 Sep 16, 2023
e9fa2ca
Remove cgu_reuse_tracker from Session
bjorn3 Sep 19, 2023
7f5af72
Remove interior mutability from CguReuseTracker
bjorn3 Sep 19, 2023
f0b5820
Fix review comments
bjorn3 Oct 5, 2023
b6b11c7
Rejig some top-level `rustc_hir_pretty` functions.
nnethercote Oct 10, 2023
51e8c80
Add unstable book page for the no-jump-tables codegen option
tgross35 Oct 10, 2023
664b185
Remove many unneeded `pub`s.
nnethercote Oct 10, 2023
494bc85
Tweak comments.
nnethercote Oct 10, 2023
7d35902
Fiddle with `State` functions.
nnethercote Oct 10, 2023
232aaeb
Handle several `#[diagnostic::on_unimplemented]` attributes correctly
weiznich Oct 11, 2023
d6056ec
Show enum discriminant if a compatible repr is used
GuillaumeGomez Oct 10, 2023
bd59fc6
Add tests for enum discriminant value display with `repr`
GuillaumeGomez Oct 10, 2023
00c3de9
Improve code documentation a bit
GuillaumeGomez Oct 11, 2023
becf494
Rename `Token::is_op` as `Token::is_punct`.
nnethercote Aug 8, 2023
129fe9a
Add a comment to `tests/ui/proc-macro/issue-75930-derive-cfg.rs`.
nnethercote Aug 8, 2023
bb9c2f5
Reorder an expression to improve readability.
nnethercote Aug 8, 2023
33aff5b
Use `TokenStream::token_alone` in one place.
nnethercote Oct 11, 2023
66c2b77
Rename `tt_prepend_space` as `space_between`.
nnethercote Oct 11, 2023
66e643d
Fix duplicate note on internal feature gate
gurry Oct 12, 2023
4f05e95
Auto merge of #116628 - gurry:116293-dup-note.rs, r=petrochenkov
bors Oct 12, 2023
3ff244b
Auto merge of #116600 - GuillaumeGomez:repr-enums-discriminant, r=fmease
bors Oct 12, 2023
a7ae2a6
coverage: Simplify the detection of reloop edges to be given expressions
Zalathar Oct 12, 2023
d1920c5
coverage: Rename `next_bcb` to just `bcb`
Zalathar Oct 12, 2023
ea3fb7b
coverage: Use a `VecDeque` for loop traversal worklists
Zalathar Oct 12, 2023
15360b3
coverage: Store a graph reference in the graph traversal struct
Zalathar Oct 11, 2023
59f4f1c
coverage: Don't store loop backedges in the traversal context
Zalathar Oct 11, 2023
d99ab97
coverage: Simplify adding BCB successors to the traversal worklists
Zalathar Oct 12, 2023
19149d1
Auto merge of #116649 - nnethercote:improve-print_tts-precursors, r=p…
bors Oct 12, 2023
8309097
Fix mips platform support entries.
ehuss Oct 12, 2023
54c528e
Rollup merge of #116593 - tgross35:no-jump-tables-docs, r=compiler-er…
matthiaskrgr Oct 12, 2023
4b1867a
Rollup merge of #116625 - nnethercote:rustc_hir_pretty, r=fee1-dead
matthiaskrgr Oct 12, 2023
5f90bee
Rollup merge of #116642 - weiznich:diagnostic_on_unimplemented_improv…
matthiaskrgr Oct 12, 2023
4832811
Rollup merge of #116654 - Zalathar:reloop-traversal, r=oli-obk
matthiaskrgr Oct 12, 2023
6ccc521
Rollup merge of #116669 - ehuss:fix-platform-table, r=nikic
matthiaskrgr Oct 12, 2023
672fad9
Auto merge of #116671 - matthiaskrgr:rollup-b41rw92, r=matthiaskrgr
bors Oct 12, 2023
f5cdd3e
Exclude apple from assembly test
scottmcm Oct 12, 2023
df4379b
Auto merge of #116510 - scottmcm:no-1-simd-v2, r=compiler-errors
bors Oct 12, 2023
ef8701a
Rename some things.
nnethercote Oct 9, 2023
c5cfcdc
Remove unnecessary call to `call_with_pp_support_hir`.
nnethercote Oct 9, 2023
87090a9
Remove an outdated comment.
nnethercote Oct 9, 2023
1467ba0
Remove PpAstTreeMode.
nnethercote Oct 10, 2023
d5e7c5f
Remove unused `PrinterSupport::hir_map` method.
nnethercote Oct 10, 2023
e3d8bbb
Simplify support traits.
nnethercote Oct 10, 2023
7d145a0
Merge `print_*` functions.
nnethercote Oct 10, 2023
060851b
Remove pretty-printing traits.
nnethercote Oct 10, 2023
ba58e32
Rename some `'hir` lifetimes as `'tcx`.
nnethercote Oct 10, 2023
b65227a
Make `needs_analysis` true for `PpHirMode::Typed`.
nnethercote Oct 10, 2023
2e2924f
Split and rename the annotation structs.
nnethercote Oct 10, 2023
2b4c338
Remove unneeded `pub`s.
nnethercote Oct 6, 2023
e20cb77
Auto merge of #116391 - Nadrieril:constructorset, r=cjgillot
bors Oct 12, 2023
130ff8c
Auto merge of #115964 - bjorn3:cgu_reuse_tracker_global_state, r=cjgi…
bors Oct 13, 2023
2763ca5
Auto merge of #116619 - nnethercote:rustc_driver_impl, r=compiler-errors
bors Oct 13, 2023
7b89422
remove excluded files from upstream
github-actions[bot] Oct 13, 2023
eba3906
pull new changes from upstream
github-actions[bot] Oct 13, 2023
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
1 change: 1 addition & 0 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4403,6 +4403,7 @@ dependencies = [
"serde_json",
"smallvec",
"tempfile",
"thin-vec",
"thorin-dwp",
"tracing",
"windows",
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast/src/attr/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ impl Attribute {
.unwrap_or_else(|| panic!("attribute is missing tokens: {self:?}"))
.to_attr_token_stream()
.to_tokenstream(),
&AttrKind::DocComment(comment_kind, data) => TokenStream::new(vec![TokenTree::Token(
Token::new(token::DocComment(comment_kind, self.style, data), self.span),
Spacing::Alone,
)]),
&AttrKind::DocComment(comment_kind, data) => TokenStream::token_alone(
token::DocComment(comment_kind, self.style, data),
self.span,
),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ impl Token {
[DotDot, DotDotDot, DotDotEq].contains(&self.kind)
}

pub fn is_op(&self) -> bool {
pub fn is_punct(&self) -> bool {
match self.kind {
Eq | Lt | Le | EqEq | Ne | Ge | Gt | AndAnd | OrOr | Not | Tilde | BinOp(_)
| BinOpEq(_) | At | Dot | DotDot | DotDotDot | DotDotEq | Comma | Semi | Colon
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_ast_pretty/src/pprust/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ pub fn print_crate<'a>(

/// This makes printed token streams look slightly nicer,
/// and also addresses some specific regressions described in #63896 and #73345.
fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
fn space_between(prev: &TokenTree, curr: &TokenTree) -> bool {
if let TokenTree::Token(token, _) = prev {
// No space after these tokens, e.g. `x.y`, `$e`
// (The carets point to `prev`.) ^ ^
Expand All @@ -159,9 +159,9 @@ fn tt_prepend_space(tt: &TokenTree, prev: &TokenTree) -> bool {
return comment_kind != CommentKind::Line;
}
}
match tt {
match curr {
// No space before these tokens, e.g. `foo,`, `println!`, `x.y`
// (The carets point to `token`.) ^ ^ ^
// (The carets point to `curr`.) ^ ^ ^
//
// FIXME: having `Not` here works well for macro invocations like
// `println!()`, but is bad when `!` means "logical not" or "the never
Expand Down Expand Up @@ -575,7 +575,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
while let Some(tt) = iter.next() {
self.print_tt(tt, convert_dollar_crate);
if let Some(next) = iter.peek() {
if tt_prepend_space(next, tt) {
if space_between(tt, next) {
self.space();
}
}
Expand Down
98 changes: 37 additions & 61 deletions compiler/rustc_codegen_cranelift/src/driver/aot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@ use std::sync::Arc;
use std::thread::JoinHandle;

use cranelift_object::{ObjectBuilder, ObjectModule};
use rustc_codegen_ssa::assert_module_sources::CguReuse;
use rustc_codegen_ssa::back::metadata::create_compressed_metadata_file;
use rustc_codegen_ssa::base::determine_cgu_reuse;
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, ModuleKind};
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::mir::mono::{CodegenUnit, MonoItem};
use rustc_session::cgu_reuse_tracker::CguReuse;
use rustc_session::config::{DebugInfo, OutputFilenames, OutputType};
use rustc_session::Session;

Expand Down Expand Up @@ -374,43 +375,47 @@ pub(crate) fn run_aot(
}
}

// Calculate the CGU reuse
let cgu_reuse = tcx.sess.time("find_cgu_reuse", || {
cgus.iter().map(|cgu| determine_cgu_reuse(tcx, &cgu)).collect::<Vec<_>>()
});

rustc_codegen_ssa::assert_module_sources::assert_module_sources(tcx, &|cgu_reuse_tracker| {
for (i, cgu) in cgus.iter().enumerate() {
let cgu_reuse = cgu_reuse[i];
cgu_reuse_tracker.set_actual_reuse(cgu.name().as_str(), cgu_reuse);
}
});

let global_asm_config = Arc::new(crate::global_asm::GlobalAsmConfig::new(tcx));

let mut concurrency_limiter = ConcurrencyLimiter::new(tcx.sess, cgus.len());

let modules = tcx.sess.time("codegen mono items", || {
cgus.iter()
.map(|cgu| {
let cgu_reuse = if backend_config.disable_incr_cache {
CguReuse::No
} else {
determine_cgu_reuse(tcx, cgu)
};
tcx.sess.cgu_reuse_tracker.set_actual_reuse(cgu.name().as_str(), cgu_reuse);

match cgu_reuse {
CguReuse::No => {
let dep_node = cgu.codegen_dep_node(tcx);
tcx.dep_graph
.with_task(
dep_node,
tcx,
(
backend_config.clone(),
global_asm_config.clone(),
cgu.name(),
concurrency_limiter.acquire(tcx.sess.diagnostic()),
),
module_codegen,
Some(rustc_middle::dep_graph::hash_result),
)
.0
}
CguReuse::PreLto => unreachable!(),
CguReuse::PostLto => {
concurrency_limiter.job_already_done();
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, cgu))
}
.enumerate()
.map(|(i, cgu)| match cgu_reuse[i] {
CguReuse::No => {
let dep_node = cgu.codegen_dep_node(tcx);
tcx.dep_graph
.with_task(
dep_node,
tcx,
(
backend_config.clone(),
global_asm_config.clone(),
cgu.name(),
concurrency_limiter.acquire(tcx.sess.diagnostic()),
),
module_codegen,
Some(rustc_middle::dep_graph::hash_result),
)
.0
}
CguReuse::PreLto => unreachable!("LTO not yet supported"),
CguReuse::PostLto => {
concurrency_limiter.job_already_done();
OngoingModuleCodegen::Sync(reuse_workproduct_for_cgu(tcx, cgu))
}
})
.collect::<Vec<_>>()
Expand Down Expand Up @@ -489,32 +494,3 @@ pub(crate) fn run_aot(
concurrency_limiter,
})
}

// Adapted from https://github.com/rust-lang/rust/blob/303d8aff6092709edd4dbd35b1c88e9aa40bf6d8/src/librustc_codegen_ssa/base.rs#L922-L953
fn determine_cgu_reuse<'tcx>(tcx: TyCtxt<'tcx>, cgu: &CodegenUnit<'tcx>) -> CguReuse {
if !tcx.dep_graph.is_fully_enabled() {
return CguReuse::No;
}

let work_product_id = &cgu.work_product_id();
if tcx.dep_graph.previous_work_product(work_product_id).is_none() {
// We don't have anything cached for this CGU. This can happen
// if the CGU did not exist in the previous session.
return CguReuse::No;
}

// Try to mark the CGU as green. If it we can do so, it means that nothing
// affecting the LLVM module has changed and we can re-use a cached version.
// If we compile with any kind of LTO, this means we can re-use the bitcode
// of the Pre-LTO stage (possibly also the Post-LTO version but we'll only
// know that later). If we are not doing LTO, there is only one optimized
// version of each module, so we re-use that.
let dep_node = cgu.codegen_dep_node(tcx);
assert!(
!tcx.dep_graph.dep_node_exists(&dep_node),
"CompileCodegenUnit dep-node for CGU `{}` already exists before marking.",
cgu.name()
);

if tcx.try_mark_green(&dep_node) { CguReuse::PostLto } else { CguReuse::No }
}
2 changes: 0 additions & 2 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::bug;
use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
use rustc_session::cgu_reuse_tracker::CguReuse;
use rustc_session::config::{self, CrateType, Lto};

use std::ffi::{CStr, CString};
Expand Down Expand Up @@ -584,7 +583,6 @@ fn thin_lto(
copy_jobs.push(work_product);
info!(" - {}: re-used", module_name);
assert!(cgcx.incr_comp_session_dir.is_some());
cgcx.cgu_reuse_tracker.set_actual_reuse(module_name, CguReuse::PostLto);
continue;
}
}
Expand Down
7 changes: 6 additions & 1 deletion compiler/rustc_codegen_llvm/src/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,12 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyAndLayout<'tcx> {
// extracts all the individual values.

let ety = element.llvm_type(cx);
return Some(cx.type_vector(ety, *count));
if *count == 1 {
// Emitting `<1 x T>` would be silly; just use the scalar.
return Some(ety);
} else {
return Some(cx.type_vector(ety, *count));
}
}

// FIXME: The above only handled integer arrays; surely more things
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_ssa/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pathdiff = "0.2.0"
serde_json = "1.0.59"
smallvec = { version = "1.8.1", features = ["union", "may_dangle"] }
regex = "1.4"
thin-vec = "0.2.12"

rustc_serialize = { path = "../rustc_serialize" }
rustc_arena = { path = "../rustc_arena" }
Expand Down
24 changes: 24 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ codegen_ssa_atomic_compare_exchange = Atomic compare-exchange intrinsic missing
codegen_ssa_binary_output_to_tty = option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty
codegen_ssa_cgu_not_recorded =
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded
codegen_ssa_check_installed_visual_studio = please ensure that Visual Studio 2017 or later, or Build Tools for Visual Studio were installed with the Visual C++ option.
codegen_ssa_copy_path = could not copy {$from} to {$to}: {$error}
Expand Down Expand Up @@ -39,13 +42,21 @@ codegen_ssa_failed_to_get_layout = failed to get layout for {$ty}: {$err}
codegen_ssa_failed_to_write = failed to write {$path}: {$error}
codegen_ssa_field_associated_value_expected = associated value expected for `{$name}`
codegen_ssa_ignoring_emit_path = ignoring emit path because multiple .{$extension} files were produced
codegen_ssa_ignoring_output = ignoring -o because multiple .{$extension} files were produced
codegen_ssa_illegal_link_ordinal_format = illegal ordinal format in `link_ordinal`
.note = an unsuffixed integer value, e.g., `1`, is expected
codegen_ssa_incorrect_cgu_reuse_type =
CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least ->
[one] {"at least "}
*[other] {""}
}`{$expected_reuse}`
codegen_ssa_insufficient_vs_code_product = VS Code is a different product, and is not sufficient.
codegen_ssa_invalid_link_ordinal_nargs = incorrect number of arguments to `#[link_ordinal]`
Expand Down Expand Up @@ -153,19 +164,30 @@ codegen_ssa_linker_unsupported_modifier = `as-needed` modifier not supported for
codegen_ssa_linking_failed = linking with `{$linker_path}` failed: {$exit_status}
codegen_ssa_malformed_cgu_name =
found malformed codegen unit name `{$user_path}`. codegen units names must always start with the name of the crate (`{$crate_name}` in this case).
codegen_ssa_metadata_object_file_write = error writing metadata object file: {$error}
codegen_ssa_missing_cpp_build_tool_component = or a necessary component may be missing from the "C++ build tools" workload
codegen_ssa_missing_memory_ordering = Atomic intrinsic missing memory ordering
codegen_ssa_missing_query_depgraph =
found CGU-reuse attribute but `-Zquery-dep-graph` was not specified
codegen_ssa_msvc_missing_linker = the msvc targets depend on the msvc linker but `link.exe` was not found
codegen_ssa_multiple_external_func_decl = multiple declarations of external function `{$function}` from library `{$library_name}` have different calling conventions
codegen_ssa_multiple_main_functions = entry symbol `main` declared multiple times
.help = did you use `#[no_mangle]` on `fn main`? Use `#[start]` instead
codegen_ssa_no_field = no field `{$name}`
codegen_ssa_no_module_named =
no module named `{$user_path}` (mangled: {$cgu_name}). available modules: {$cgu_names}
codegen_ssa_no_natvis_directory = error enumerating natvis directory: {$error}
codegen_ssa_processing_dymutil_failed = processing debug info with `dsymutil` failed: {$status}
Expand Down Expand Up @@ -297,6 +319,8 @@ codegen_ssa_unknown_atomic_operation = unknown atomic operation
codegen_ssa_unknown_atomic_ordering = unknown ordering in atomic intrinsic
codegen_ssa_unknown_reuse_kind = unknown cgu-reuse-kind `{$kind}` specified
codegen_ssa_unsupported_arch = unsupported arch `{$arch}` for os `{$os}`
codegen_ssa_unsupported_link_self_contained = option `-C link-self-contained` is not supported on this target
Expand Down
Loading