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 8 pull requests #96653

Closed
wants to merge 22 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
9625ed8
Move settings into full JS
GuillaumeGomez Jan 19, 2022
e7d7d75
Add GUI test for settings menu
GuillaumeGomez Jan 19, 2022
2f074de
Extend settings test to ensure settings text is as expected
GuillaumeGomez Apr 29, 2022
09f758f
Remove ```` ```ignore```` from E0705 test
CAD97 Apr 30, 2022
336bb0a
Rename run_lto_pass_manager to optimize_fat and remove thin parameter
bjorn3 Apr 30, 2022
ee94ff2
Let LtoModuleCodegen::optimize take self by value
bjorn3 Apr 30, 2022
fab7230
Remove config parameter of optimize_fat and avoid interior mutability…
bjorn3 Apr 30, 2022
78c65a5
Merge new_metadata into codegen_allocator
bjorn3 Apr 30, 2022
685f66b
Use source callsite in check_argument_types suggestion
Badel2 Apr 30, 2022
121c978
Revert #92191 Prefer projection candidates instead of param_env candi…
jackh726 May 1, 2022
73688e4
* Add documentation for settings page rendering functions.
GuillaumeGomez May 1, 2022
18b12fa
Add a regression test for #92305
JohnTitor May 1, 2022
0349f8b
Use a yes/no enum instead of a bool.
oli-obk May 2, 2022
7790b6e
Mitigate impact of subtle invalid call suggestion logic
estebank May 2, 2022
60b238b
Rollup merge of #93097 - GuillaumeGomez:settings-js, r=jsha
GuillaumeGomez May 2, 2022
3ff71e9
Rollup merge of #96580 - CAD97:E0705-no-ignore, r=michaelwoerister
GuillaumeGomez May 2, 2022
23785c2
Rollup merge of #96587 - bjorn3:refactor_backend_write, r=michaelwoer…
GuillaumeGomez May 2, 2022
a0e2a37
Rollup merge of #96589 - Badel2:source-callsite, r=michaelwoerister
GuillaumeGomez May 2, 2022
393705b
Rollup merge of #96593 - jackh726:issue-93262, r=compiler-errors
GuillaumeGomez May 2, 2022
cffbc43
Rollup merge of #96614 - JohnTitor:test-92305, r=oli-obk
GuillaumeGomez May 2, 2022
c161dcc
Rollup merge of #96641 - oli-obk:bool_args, r=wesleywiser
GuillaumeGomez May 2, 2022
ed7ce52
Rollup merge of #96646 - estebank:issue-96638, r=jackh726
GuillaumeGomez May 2, 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
26 changes: 12 additions & 14 deletions compiler/rustc_codegen_gcc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,12 @@ impl CodegenBackend for GccCodegenBackend {
}

impl ExtraBackendMethods for GccCodegenBackend {
fn new_metadata<'tcx>(&self, _tcx: TyCtxt<'tcx>, _mod_name: &str) -> Self::Module {
GccContext {
fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) -> Self::Module {
let mut mods = GccContext {
context: Context::default(),
}
}

fn codegen_allocator<'tcx>(&self, tcx: TyCtxt<'tcx>, mods: &mut Self::Module, module_name: &str, kind: AllocatorKind, has_alloc_error_handler: bool) {
unsafe { allocator::codegen(tcx, mods, module_name, kind, has_alloc_error_handler) }
};
unsafe { allocator::codegen(tcx, &mut mods, module_name, kind, has_alloc_error_handler); }
mods
}

fn compile_codegen_unit<'tcx>(&self, tcx: TyCtxt<'tcx>, cgu_name: Symbol) -> (ModuleCodegen<Self::Module>, u64) {
Expand Down Expand Up @@ -213,7 +211,7 @@ impl WriteBackendMethods for GccCodegenBackend {
unimplemented!();
}
};
Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: vec![] })
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: vec![] })
}

fn run_thin_lto(_cgcx: &CodegenContext<Self>, _modules: Vec<(String, Self::ThinBuffer)>, _cached_modules: Vec<(SerializedModule<Self::ModuleBuffer>, WorkProduct)>) -> Result<(Vec<LtoModuleCodegen<Self>>, Vec<WorkProduct>), FatalError> {
Expand All @@ -229,7 +227,12 @@ impl WriteBackendMethods for GccCodegenBackend {
Ok(())
}

unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: &mut ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
fn optimize_fat(_cgcx: &CodegenContext<Self>, _module: &mut ModuleCodegen<Self::Module>) -> Result<(), FatalError> {
// TODO(antoyo)
Ok(())
}

unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: ThinModule<Self>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
unimplemented!();
}

Expand All @@ -245,11 +248,6 @@ impl WriteBackendMethods for GccCodegenBackend {
unimplemented!();
}

fn run_lto_pass_manager(_cgcx: &CodegenContext<Self>, _module: &ModuleCodegen<Self::Module>, _config: &ModuleConfig, _thin: bool) -> Result<(), FatalError> {
// TODO(antoyo)
Ok(())
}

fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &Handler, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
back::write::link(cgcx, diag_handler, modules)
}
Expand Down
17 changes: 7 additions & 10 deletions compiler/rustc_codegen_llvm/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ use crate::llvm::{self, build_string, False, True};
use crate::{llvm_util, LlvmCodegenBackend, ModuleLlvm};
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule, ThinShared};
use rustc_codegen_ssa::back::symbol_export;
use rustc_codegen_ssa::back::write::{
CodegenContext, FatLTOInput, ModuleConfig, TargetMachineFactoryConfig,
};
use rustc_codegen_ssa::back::write::{CodegenContext, FatLTOInput, TargetMachineFactoryConfig};
use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
use rustc_data_structures::fx::FxHashMap;
Expand Down Expand Up @@ -353,7 +351,7 @@ fn fat_lto(
}
}

Ok(LtoModuleCodegen::Fat { module: Some(module), _serialized_bitcode: serialized_bitcode })
Ok(LtoModuleCodegen::Fat { module, _serialized_bitcode: serialized_bitcode })
}

crate struct Linker<'a>(&'a mut llvm::Linker<'a>);
Expand Down Expand Up @@ -578,11 +576,11 @@ fn thin_lto(
pub(crate) fn run_pass_manager(
cgcx: &CodegenContext<LlvmCodegenBackend>,
diag_handler: &Handler,
module: &ModuleCodegen<ModuleLlvm>,
config: &ModuleConfig,
module: &mut ModuleCodegen<ModuleLlvm>,
thin: bool,
) -> Result<(), FatalError> {
let _timer = cgcx.prof.extra_verbose_generic_activity("LLVM_lto_optimize", &*module.name);
let config = cgcx.config(module.kind);

// Now we have one massive module inside of llmod. Time to run the
// LTO-specific optimization passes that LLVM provides.
Expand Down Expand Up @@ -726,7 +724,7 @@ impl Drop for ThinBuffer {
}

pub unsafe fn optimize_thin_module(
thin_module: &mut ThinModule<LlvmCodegenBackend>,
thin_module: ThinModule<LlvmCodegenBackend>,
cgcx: &CodegenContext<LlvmCodegenBackend>,
) -> Result<ModuleCodegen<ModuleLlvm>, FatalError> {
let diag_handler = cgcx.create_diag_handler();
Expand All @@ -743,7 +741,7 @@ pub unsafe fn optimize_thin_module(
// that LLVM Context and Module.
let llcx = llvm::LLVMRustContextCreate(cgcx.fewer_names);
let llmod_raw = parse_module(llcx, module_name, thin_module.data(), &diag_handler)? as *const _;
let module = ModuleCodegen {
let mut module = ModuleCodegen {
module_llvm: ModuleLlvm { llmod_raw, llcx, tm },
name: thin_module.name().to_string(),
kind: ModuleKind::Regular,
Expand Down Expand Up @@ -859,8 +857,7 @@ pub unsafe fn optimize_thin_module(
// little differently.
{
info!("running thin lto passes over {}", module.name);
let config = cgcx.config(module.kind);
run_pass_manager(cgcx, &diag_handler, &module, config, true)?;
run_pass_manager(cgcx, &diag_handler, &mut module, true)?;
save_temp_bitcode(cgcx, &module, "thin-lto-after-pm");
}
}
Expand Down
31 changes: 14 additions & 17 deletions compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,18 @@ impl Drop for TimeTraceProfiler {
}

impl ExtraBackendMethods for LlvmCodegenBackend {
fn new_metadata(&self, tcx: TyCtxt<'_>, mod_name: &str) -> ModuleLlvm {
ModuleLlvm::new_metadata(tcx, mod_name)
}

fn codegen_allocator<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
module_llvm: &mut ModuleLlvm,
module_name: &str,
kind: AllocatorKind,
has_alloc_error_handler: bool,
) {
unsafe { allocator::codegen(tcx, module_llvm, module_name, kind, has_alloc_error_handler) }
) -> ModuleLlvm {
let mut module_llvm = ModuleLlvm::new_metadata(tcx, module_name);
unsafe {
allocator::codegen(tcx, &mut module_llvm, module_name, kind, has_alloc_error_handler);
}
module_llvm
}
fn compile_codegen_unit(
&self,
Expand Down Expand Up @@ -210,9 +209,16 @@ impl WriteBackendMethods for LlvmCodegenBackend {
) -> Result<(), FatalError> {
back::write::optimize(cgcx, diag_handler, module, config)
}
fn optimize_fat(
cgcx: &CodegenContext<Self>,
module: &mut ModuleCodegen<Self::Module>,
) -> Result<(), FatalError> {
let diag_handler = cgcx.create_diag_handler();
back::lto::run_pass_manager(cgcx, &diag_handler, module, false)
}
unsafe fn optimize_thin(
cgcx: &CodegenContext<Self>,
thin: &mut ThinModule<Self>,
thin: ThinModule<Self>,
) -> Result<ModuleCodegen<Self::Module>, FatalError> {
back::lto::optimize_thin_module(thin, cgcx)
}
Expand All @@ -230,15 +236,6 @@ impl WriteBackendMethods for LlvmCodegenBackend {
fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {
(module.name, back::lto::ModuleBuffer::new(module.module_llvm.llmod()))
}
fn run_lto_pass_manager(
cgcx: &CodegenContext<Self>,
module: &ModuleCodegen<Self::Module>,
config: &ModuleConfig,
thin: bool,
) -> Result<(), FatalError> {
let diag_handler = cgcx.create_diag_handler();
back::lto::run_pass_manager(cgcx, &diag_handler, module, config, thin)
}
}

unsafe impl Send for LlvmCodegenBackend {} // Llvm is on a per-thread basis
Expand Down
16 changes: 6 additions & 10 deletions compiler/rustc_codegen_ssa/src/back/lto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub struct ThinShared<B: WriteBackendMethods> {

pub enum LtoModuleCodegen<B: WriteBackendMethods> {
Fat {
module: Option<ModuleCodegen<B::Module>>,
module: ModuleCodegen<B::Module>,
_serialized_bitcode: Vec<SerializedModule<B::ModuleBuffer>>,
},

Expand All @@ -64,19 +64,15 @@ impl<B: WriteBackendMethods> LtoModuleCodegen<B> {
/// It's intended that the module returned is immediately code generated and
/// dropped, and then this LTO module is dropped.
pub unsafe fn optimize(
&mut self,
self,
cgcx: &CodegenContext<B>,
) -> Result<ModuleCodegen<B::Module>, FatalError> {
match *self {
LtoModuleCodegen::Fat { ref mut module, .. } => {
let module = module.take().unwrap();
{
let config = cgcx.config(module.kind);
B::run_lto_pass_manager(cgcx, &module, config, false)?;
}
match self {
LtoModuleCodegen::Fat { mut module, .. } => {
B::optimize_fat(cgcx, &mut module)?;
Ok(module)
}
LtoModuleCodegen::Thin(ref mut thin) => B::optimize_thin(cgcx, thin),
LtoModuleCodegen::Thin(thin) => B::optimize_thin(cgcx, thin),
}
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(

fn execute_lto_work_item<B: ExtraBackendMethods>(
cgcx: &CodegenContext<B>,
mut module: lto::LtoModuleCodegen<B>,
module: lto::LtoModuleCodegen<B>,
module_config: &ModuleConfig,
) -> Result<WorkItemResult<B>, FatalError> {
let module = unsafe { module.optimize(cgcx)? };
Expand Down
11 changes: 2 additions & 9 deletions compiler/rustc_codegen_ssa/src/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,15 +575,8 @@ pub fn codegen_crate<B: ExtraBackendMethods>(
} else if let Some(kind) = tcx.allocator_kind(()) {
let llmod_id =
cgu_name_builder.build_cgu_name(LOCAL_CRATE, &["crate"], Some("allocator")).to_string();
let mut module_llvm = backend.new_metadata(tcx, &llmod_id);
tcx.sess.time("write_allocator_module", || {
backend.codegen_allocator(
tcx,
&mut module_llvm,
&llmod_id,
kind,
tcx.lang_items().oom().is_some(),
)
let module_llvm = tcx.sess.time("write_allocator_module", || {
backend.codegen_allocator(tcx, &llmod_id, kind, tcx.lang_items().oom().is_some())
});

Some(ModuleCodegen { name: llmod_id, module_llvm, kind: ModuleKind::Allocator })
Expand Down
4 changes: 1 addition & 3 deletions compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,13 @@ pub trait CodegenBackend {
}

pub trait ExtraBackendMethods: CodegenBackend + WriteBackendMethods + Sized + Send + Sync {
fn new_metadata(&self, sess: TyCtxt<'_>, mod_name: &str) -> Self::Module;
fn codegen_allocator<'tcx>(
&self,
tcx: TyCtxt<'tcx>,
module_llvm: &mut Self::Module,
module_name: &str,
kind: AllocatorKind,
has_alloc_error_handler: bool,
);
) -> Self::Module;
/// This generates the codegen unit and returns it along with
/// a `u64` giving an estimate of the unit's processing cost.
fn compile_codegen_unit(
Expand Down
12 changes: 5 additions & 7 deletions compiler/rustc_codegen_ssa/src/traits/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,13 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
module: &ModuleCodegen<Self::Module>,
config: &ModuleConfig,
) -> Result<(), FatalError>;
fn optimize_fat(
cgcx: &CodegenContext<Self>,
llmod: &mut ModuleCodegen<Self::Module>,
) -> Result<(), FatalError>;
unsafe fn optimize_thin(
cgcx: &CodegenContext<Self>,
thin: &mut ThinModule<Self>,
thin: ThinModule<Self>,
) -> Result<ModuleCodegen<Self::Module>, FatalError>;
unsafe fn codegen(
cgcx: &CodegenContext<Self>,
Expand All @@ -53,12 +57,6 @@ pub trait WriteBackendMethods: 'static + Sized + Clone {
) -> Result<CompiledModule, FatalError>;
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer);
fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer);
fn run_lto_pass_manager(
cgcx: &CodegenContext<Self>,
llmod: &ModuleCodegen<Self::Module>,
config: &ModuleConfig,
thin: bool,
) -> Result<(), FatalError>;
}

pub trait ThinBufferMethods: Send + Sync {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_error_codes/src/error_codes/E0705.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ current edition, but not in all editions.

Erroneous code example:

```ignore (limited to a warning during 2018 edition development)
```rust2018,compile_fail,E0705
#![feature(rust_2018_preview)]
#![feature(test_2018_feature)] // error: the feature
// `test_2018_feature` is
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,7 +1179,7 @@ impl<'a> Resolver<'a> {
ConstantItemRibKind(trivial, _) => {
let features = self.session.features_untracked();
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
if !(trivial || features.generic_const_exprs) {
if !(trivial == HasGenericParams::Yes || features.generic_const_exprs) {
// HACK(min_const_generics): If we encounter `Self` in an anonymous constant
// we can't easily tell if it's generic at this stage, so we instead remember
// this and then enforce the self type to be concrete later on.
Expand Down Expand Up @@ -1267,7 +1267,7 @@ impl<'a> Resolver<'a> {
ConstantItemRibKind(trivial, _) => {
let features = self.session.features_untracked();
// HACK(min_const_generics): We currently only allow `N` or `{ N }`.
if !(trivial || features.generic_const_exprs) {
if !(trivial == HasGenericParams::Yes || features.generic_const_exprs) {
if let Some(span) = finalize {
self.report_error(
span,
Expand Down
Loading