Merge pull request #450 from rust-lang/sync_from_rust_2024_02_20

Sync from rust 2024/02/20
This commit is contained in:
antoyo 2024-02-20 17:01:46 -05:00 committed by GitHub
commit e785093382
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
28 changed files with 166 additions and 190 deletions

4
Cargo.lock generated
View File

@ -126,9 +126,9 @@ dependencies = [
[[package]] [[package]]
name = "libc" name = "libc"
version = "0.2.147" version = "0.2.150"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b4668fb0ea861c1df094127ac5f1da3409a82116a4ba74fca2e58ef927159bb3" checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c"
[[package]] [[package]]
name = "linux-raw-sys" name = "linux-raw-sys"

View File

@ -159,21 +159,6 @@ fn clone_and_setup<F>(repo_url: &str, checkout_commit: &str, extra: Option<F>) -
let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name); let repo_path = Path::new(crate::BUILD_DIR).join(&clone_result.repo_name);
run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?; run_command(&[&"git", &"checkout", &"--", &"."], Some(&repo_path))?;
run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?; run_command(&[&"git", &"checkout", &checkout_commit], Some(&repo_path))?;
let filter = format!("-{}-", clone_result.repo_name);
walk_dir(
"patches/crate_patches",
|_| Ok(()),
|file_path| {
let patch = file_path.as_os_str().to_str().unwrap();
if patch.contains(&filter) && patch.ends_with(".patch") {
run_command_with_output(
&[&"git", &"am", &file_path.canonicalize().unwrap()],
Some(&repo_path),
)?;
}
Ok(())
},
)?;
if let Some(extra) = extra { if let Some(extra) = extra {
extra(&repo_path)?; extra(&repo_path)?;
} }
@ -238,7 +223,7 @@ pub fn run() -> Result<(), String> {
let to_clone = &[ let to_clone = &[
( (
"https://github.com/rust-random/rand.git", "https://github.com/rust-random/rand.git",
"0f933f9c7176e53b2a3c7952ded484e1783f0bf1", "1f4507a8e1cf8050e4ceef95eeda8f64645b6719",
None, None,
), ),
( (

View File

@ -4,7 +4,7 @@
thread_local thread_local
)] )]
#![no_core] #![no_core]
#![allow(dead_code, internal_features)] #![allow(dead_code, internal_features, ambiguous_wide_pointer_comparisons)]
#[no_mangle] #[no_mangle]
unsafe extern "C" fn _Unwind_Resume() { unsafe extern "C" fn _Unwind_Resume() {
@ -100,9 +100,6 @@ unsafe impl<T: ?Sized> Freeze for &mut T {}
#[lang = "structural_peq"] #[lang = "structural_peq"]
pub trait StructuralPartialEq {} pub trait StructuralPartialEq {}
#[lang = "structural_teq"]
pub trait StructuralEq {}
#[lang = "not"] #[lang = "not"]
pub trait Not { pub trait Not {
type Output; type Output;

View File

@ -98,6 +98,9 @@ fn start<T: Termination + 'static>(
} }
static mut NUM: u8 = 6 * 7; static mut NUM: u8 = 6 * 7;
// FIXME: Use `SyncUnsafeCell` instead of allowing `static_mut_refs` lint
#[allow(static_mut_refs)]
static NUM_REF: &'static u8 = unsafe { &NUM }; static NUM_REF: &'static u8 = unsafe { &NUM };
macro_rules! assert { macro_rules! assert {

View File

@ -1,3 +1,4 @@
#![allow(internal_features)]
#![feature(core_intrinsics, coroutines, coroutine_trait, is_sorted)] #![feature(core_intrinsics, coroutines, coroutine_trait, is_sorted)]
#[cfg(feature="master")] #[cfg(feature="master")]

View File

@ -39,6 +39,4 @@ index 42a26ae..5ac1042 100644
+#![cfg(test)] +#![cfg(test)]
#![feature(alloc_layout_extra)] #![feature(alloc_layout_extra)]
#![feature(array_chunks)] #![feature(array_chunks)]
#![feature(array_methods)] #![feature(array_windows)]
--
2.21.0 (Apple Git-122)

View File

@ -1,32 +0,0 @@
From a8fb97120d71252538b6b026695df40d02696bdb Mon Sep 17 00:00:00 2001
From: bjorn3 <bjorn3@users.noreply.github.com>
Date: Sat, 15 Aug 2020 20:04:38 +0200
Subject: [PATCH] [rand] Disable failing test
---
src/distributions/uniform.rs | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/distributions/uniform.rs b/src/distributions/uniform.rs
index 480b859..c80bb6f 100644
--- a/src/distributions/uniform.rs
+++ b/src/distributions/uniform.rs
@@ -1085,7 +1085,7 @@ mod tests {
_ => panic!("`UniformDurationMode` was not serialized/deserialized correctly")
}
}
-
+
#[test]
#[cfg(feature = "serde1")]
fn test_uniform_serialization() {
@@ -1314,6 +1314,7 @@ mod tests {
not(target_arch = "wasm32"),
not(target_arch = "asmjs")
))]
+ #[ignore] // FIXME
fn test_float_assertions() {
use super::SampleUniform;
use std::panic::catch_unwind;
--
2.20.1

View File

@ -21,19 +21,3 @@ index 5b21355..cb0c49b 100644
[dependencies] [dependencies]
alloc = { path = "../alloc", public = true } alloc = { path = "../alloc", public = true }
diff --git a/library/test/Cargo.toml b/library/test/Cargo.toml
index 91a1abd..a58c160 100644
--- a/library/test/Cargo.toml
+++ b/library/test/Cargo.toml
@@ -4,7 +4,7 @@ version = "0.0.0"
edition = "2021"
[lib]
-crate-type = ["dylib", "rlib"]
+crate-type = ["rlib"]
[dependencies]
getopts = { version = "0.2.21", features = ['rustc-dep-of-std'] }
--
2.42.0

View File

@ -1,3 +1,3 @@
[toolchain] [toolchain]
channel = "nightly-2023-11-17" channel = "nightly-2024-02-20"
components = ["rust-src", "rustc-dev", "llvm-tools-preview"] components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

View File

@ -90,7 +90,7 @@ fn create_wrapper_function(
.collect(); .collect();
let func = context.new_function(None, FunctionType::Exported, output.unwrap_or(void), &args, from_name, false); let func = context.new_function(None, FunctionType::Exported, output.unwrap_or(void), &args, from_name, false);
if tcx.sess.target.options.default_hidden_visibility { if tcx.sess.default_hidden_visibility() {
#[cfg(feature="master")] #[cfg(feature="master")]
func.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden)); func.add_attribute(FnAttribute::Visibility(gccjit::Visibility::Hidden));
} }

View File

@ -109,7 +109,7 @@ enum ConstraintOrRegister {
impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) { fn codegen_inline_asm(&mut self, template: &[InlineAsmTemplatePiece], rust_operands: &[InlineAsmOperandRef<'tcx, Self>], options: InlineAsmOptions, span: &[Span], instance: Instance<'_>, _dest_catch_funclet: Option<(Self::BasicBlock, Self::BasicBlock, Option<&Self::Funclet>)>) {
if options.contains(InlineAsmOptions::MAY_UNWIND) { if options.contains(InlineAsmOptions::MAY_UNWIND) {
self.sess() self.sess().dcx()
.create_err(UnwindingInlineAsm { span: span[0] }) .create_err(UnwindingInlineAsm { span: span[0] })
.emit(); .emit();
return; return;
@ -634,6 +634,7 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
} }
InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r", InlineAsmRegClass::Wasm(WasmInlineAsmRegClass::local) => "r",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r", InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => "r",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg_addr) => "a",
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f", InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => "f",
InlineAsmRegClass::Err => unreachable!(), InlineAsmRegClass::Err => unreachable!(),
} }
@ -704,7 +705,9 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => { InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
bug!("LLVM backend does not support SPIR-V") bug!("LLVM backend does not support SPIR-V")
}, },
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::reg) => cx.type_i32(), InlineAsmRegClass::S390x(
S390xInlineAsmRegClass::reg | S390xInlineAsmRegClass::reg_addr
) => cx.type_i32(),
InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(), InlineAsmRegClass::S390x(S390xInlineAsmRegClass::freg) => cx.type_f64(),
InlineAsmRegClass::Err => unreachable!(), InlineAsmRegClass::Err => unreachable!(),
} }

View File

@ -62,9 +62,6 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) { if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::COLD) {
func.add_attribute(FnAttribute::Cold); func.add_attribute(FnAttribute::Cold);
} }
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_RETURNS_TWICE) {
func.add_attribute(FnAttribute::ReturnsTwice);
}
if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) { if codegen_fn_attrs.flags.contains(CodegenFnAttrFlags::FFI_PURE) {
func.add_attribute(FnAttribute::Pure); func.add_attribute(FnAttribute::Pure);
} }
@ -80,7 +77,7 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
let span = cx.tcx let span = cx.tcx
.get_attr(instance.def_id(), sym::target_feature) .get_attr(instance.def_id(), sym::target_feature)
.map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span); .map_or_else(|| cx.tcx.def_span(instance.def_id()), |a| a.span);
cx.tcx.sess.create_err(TiedTargetFeatures { cx.tcx.dcx().create_err(TiedTargetFeatures {
features: features.join(", "), features: features.join(", "),
span, span,
}) })

View File

@ -30,7 +30,7 @@
use rustc_codegen_ssa::traits::*; use rustc_codegen_ssa::traits::*;
use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind}; use rustc_codegen_ssa::{looks_like_rust_object_file, ModuleCodegen, ModuleKind};
use rustc_data_structures::memmap::Mmap; use rustc_data_structures::memmap::Mmap;
use rustc_errors::{FatalError, Handler}; use rustc_errors::{FatalError, DiagCtxt};
use rustc_hir::def_id::LOCAL_CRATE; use rustc_hir::def_id::LOCAL_CRATE;
use rustc_middle::dep_graph::WorkProduct; use rustc_middle::dep_graph::WorkProduct;
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel}; use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
@ -61,7 +61,7 @@ struct LtoData {
tmp_path: TempDir, tmp_path: TempDir,
} }
fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler) -> Result<LtoData, FatalError> { fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, dcx: &DiagCtxt) -> Result<LtoData, FatalError> {
let export_threshold = match cgcx.lto { let export_threshold = match cgcx.lto {
// We're just doing LTO for our one crate // We're just doing LTO for our one crate
Lto::ThinLocal => SymbolExportLevel::Rust, Lto::ThinLocal => SymbolExportLevel::Rust,
@ -106,18 +106,18 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler)
// Make sure we actually can run LTO // Make sure we actually can run LTO
for crate_type in cgcx.crate_types.iter() { for crate_type in cgcx.crate_types.iter() {
if !crate_type_allows_lto(*crate_type) { if !crate_type_allows_lto(*crate_type) {
diag_handler.emit_err(LtoDisallowed); dcx.emit_err(LtoDisallowed);
return Err(FatalError); return Err(FatalError);
} else if *crate_type == CrateType::Dylib { } else if *crate_type == CrateType::Dylib {
if !cgcx.opts.unstable_opts.dylib_lto { if !cgcx.opts.unstable_opts.dylib_lto {
diag_handler.emit_err(LtoDylib); dcx.emit_err(LtoDylib);
return Err(FatalError); return Err(FatalError);
} }
} }
} }
if cgcx.opts.cg.prefer_dynamic && !cgcx.opts.unstable_opts.dylib_lto { if cgcx.opts.cg.prefer_dynamic && !cgcx.opts.unstable_opts.dylib_lto {
diag_handler.emit_err(DynamicLinkingWithLTO); dcx.emit_err(DynamicLinkingWithLTO);
return Err(FatalError); return Err(FatalError);
} }
@ -154,7 +154,7 @@ fn prepare_lto(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler)
upstream_modules.push((module, CString::new(name).unwrap())); upstream_modules.push((module, CString::new(name).unwrap()));
} }
Err(e) => { Err(e) => {
diag_handler.emit_err(e); dcx.emit_err(e);
return Err(FatalError); return Err(FatalError);
} }
} }
@ -183,16 +183,16 @@ pub(crate) fn run_fat(
modules: Vec<FatLtoInput<GccCodegenBackend>>, modules: Vec<FatLtoInput<GccCodegenBackend>>,
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> { ) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
let diag_handler = cgcx.create_diag_handler(); let dcx = cgcx.create_dcx();
let lto_data = prepare_lto(cgcx, &diag_handler)?; let lto_data = prepare_lto(cgcx, &dcx)?;
/*let symbols_below_threshold = /*let symbols_below_threshold =
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/ lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
fat_lto(cgcx, &diag_handler, modules, cached_modules, lto_data.upstream_modules, lto_data.tmp_path, fat_lto(cgcx, &dcx, modules, cached_modules, lto_data.upstream_modules, lto_data.tmp_path,
//&symbols_below_threshold, //&symbols_below_threshold,
) )
} }
fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir, fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _dcx: &DiagCtxt, modules: Vec<FatLtoInput<GccCodegenBackend>>, cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>, mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>, tmp_path: TempDir,
//symbols_below_threshold: &[*const libc::c_char], //symbols_below_threshold: &[*const libc::c_char],
) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> { ) -> Result<LtoModuleCodegen<GccCodegenBackend>, FatalError> {
let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module"); let _timer = cgcx.prof.generic_activity("GCC_fat_lto_build_monolithic_module");
@ -257,7 +257,7 @@ fn fat_lto(cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mo
let (buffer, name) = serialized_modules.remove(0); let (buffer, name) = serialized_modules.remove(0);
info!("no in-memory regular modules to choose from, parsing {:?}", name); info!("no in-memory regular modules to choose from, parsing {:?}", name);
ModuleCodegen { ModuleCodegen {
module_llvm: GccContext::parse(cgcx, &name, buffer.data(), diag_handler)?, module_llvm: GccContext::parse(cgcx, &name, buffer.data(), dcx)?,
name: name.into_string().unwrap(), name: name.into_string().unwrap(),
kind: ModuleKind::Regular, kind: ModuleKind::Regular,
}*/ }*/

View File

@ -4,7 +4,7 @@
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen}; use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
use rustc_codegen_ssa::back::link::ensure_removed; use rustc_codegen_ssa::back::link::ensure_removed;
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig}; use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
use rustc_errors::Handler; use rustc_errors::DiagCtxt;
use rustc_fs_util::link_or_copy; use rustc_fs_util::link_or_copy;
use rustc_session::config::OutputType; use rustc_session::config::OutputType;
use rustc_span::fatal_error::FatalError; use rustc_span::fatal_error::FatalError;
@ -13,7 +13,7 @@
use crate::{GccCodegenBackend, GccContext}; use crate::{GccCodegenBackend, GccContext};
use crate::errors::CopyBitcode; use crate::errors::CopyBitcode;
pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_handler: &Handler, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> { pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, dcx: &DiagCtxt, module: ModuleCodegen<GccContext>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name); let _timer = cgcx.prof.generic_activity_with_arg("GCC_module_codegen", &*module.name);
{ {
let context = &module.module_llvm.context; let context = &module.module_llvm.context;
@ -128,12 +128,12 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
EmitObj::Bitcode => { EmitObj::Bitcode => {
debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out); debug!("copying bitcode {:?} to obj {:?}", bc_out, obj_out);
if let Err(err) = link_or_copy(&bc_out, &obj_out) { if let Err(err) = link_or_copy(&bc_out, &obj_out) {
diag_handler.emit_err(CopyBitcode { err }); dcx.emit_err(CopyBitcode { err });
} }
if !config.emit_bc { if !config.emit_bc {
debug!("removing_bitcode {:?}", bc_out); debug!("removing_bitcode {:?}", bc_out);
ensure_removed(diag_handler, &bc_out); ensure_removed(dcx, &bc_out);
} }
} }
@ -149,7 +149,7 @@ pub(crate) unsafe fn codegen(cgcx: &CodegenContext<GccCodegenBackend>, diag_hand
)) ))
} }
pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _diag_handler: &Handler, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> { pub(crate) fn link(_cgcx: &CodegenContext<GccCodegenBackend>, _dcx: &DiagCtxt, mut _modules: Vec<ModuleCodegen<GccContext>>) -> Result<ModuleCodegen<GccContext>, FatalError> {
unimplemented!(); unimplemented!();
} }

View File

@ -1313,7 +1313,7 @@ fn catch_switch(
} }
// Atomic Operations // Atomic Operations
fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> RValue<'gcc> { fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering, failure_order: AtomicOrdering, weak: bool) -> (RValue<'gcc>, RValue<'gcc>) {
let expected = self.current_func().new_local(None, cmp.get_type(), "expected"); let expected = self.current_func().new_local(None, cmp.get_type(), "expected");
self.llbb().add_assignment(None, expected, cmp); self.llbb().add_assignment(None, expected, cmp);
// NOTE: gcc doesn't support a failure memory model that is stronger than the success // NOTE: gcc doesn't support a failure memory model that is stronger than the success
@ -1327,20 +1327,12 @@ fn atomic_cmpxchg(&mut self, dst: RValue<'gcc>, cmp: RValue<'gcc>, src: RValue<'
}; };
let success = self.compare_exchange(dst, expected, src, order, failure_order, weak); let success = self.compare_exchange(dst, expected, src, order, failure_order, weak);
let pair_type = self.cx.type_struct(&[src.get_type(), self.bool_type], false); // NOTE: since success contains the call to the intrinsic, it must be added to the basic block before
let result = self.current_func().new_local(None, pair_type, "atomic_cmpxchg_result");
let align = Align::from_bits(64).expect("align"); // TODO(antoyo): use good align.
let value_type = result.to_rvalue().get_type();
if let Some(struct_type) = value_type.is_struct() {
self.store(success, result.access_field(None, struct_type.get_field(1)).get_address(None), align);
// NOTE: since success contains the call to the intrinsic, it must be stored before
// expected so that we store expected after the call. // expected so that we store expected after the call.
self.store(expected.to_rvalue(), result.access_field(None, struct_type.get_field(0)).get_address(None), align); let success_var = self.current_func().new_local(None, self.bool_type, "success");
} self.llbb().add_assignment(None, success_var, success);
// TODO(antoyo): handle when value is not a struct.
result.to_rvalue() (expected.to_rvalue(), success_var.to_rvalue())
} }
fn atomic_rmw(&mut self, op: AtomicRmwBinOp, dst: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering) -> RValue<'gcc> { fn atomic_rmw(&mut self, op: AtomicRmwBinOp, dst: RValue<'gcc>, src: RValue<'gcc>, order: AtomicOrdering) -> RValue<'gcc> {

View File

@ -199,7 +199,8 @@ fn scalar_to_backend(&self, cv: Scalar, layout: abi::Scalar, ty: Type<'gcc>) ->
} }
} }
Scalar::Ptr(ptr, _size) => { Scalar::Ptr(ptr, _size) => {
let (alloc_id, offset) = ptr.into_parts(); let (prov, offset) = ptr.into_parts(); // we know the `offset` is relative
let alloc_id = prov.alloc_id();
let base_addr = let base_addr =
match self.tcx.global_alloc(alloc_id) { match self.tcx.global_alloc(alloc_id) {
GlobalAlloc::Memory(alloc) => { GlobalAlloc::Memory(alloc) => {
@ -376,9 +377,6 @@ pub trait TypeReflection<'gcc, 'tcx> {
fn is_i128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; fn is_i128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
fn is_u128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool; fn is_u128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
fn is_f32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
fn is_f64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool;
fn is_vector(&self) -> bool; fn is_vector(&self) -> bool;
} }
@ -463,14 +461,6 @@ fn is_u128(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool {
self.unqualified() == cx.u128_type.unqualified() self.unqualified() == cx.u128_type.unqualified()
} }
fn is_f32(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool {
self.unqualified() == cx.context.new_type::<f32>()
}
fn is_f64(&self, cx: &CodegenCx<'gcc, 'tcx>) -> bool {
self.unqualified() == cx.context.new_type::<f64>()
}
fn is_vector(&self) -> bool { fn is_vector(&self) -> bool {
let mut typ = self.clone(); let mut typ = self.clone();
loop { loop {

View File

@ -24,7 +24,7 @@ fn set_global_alignment<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, gv: LValue<'gcc>
match Align::from_bits(min) { match Align::from_bits(min) {
Ok(min) => align = align.max(min), Ok(min) => align = align.max(min),
Err(err) => { Err(err) => {
cx.sess().emit_err(InvalidMinimumAlignment { err: err.to_string() }); cx.sess().dcx().emit_err(InvalidMinimumAlignment { err: err.to_string() });
} }
} }
} }
@ -285,7 +285,8 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
let pointer_size = dl.pointer_size.bytes() as usize; let pointer_size = dl.pointer_size.bytes() as usize;
let mut next_offset = 0; let mut next_offset = 0;
for &(offset, alloc_id) in alloc.provenance().ptrs().iter() { for &(offset, prov) in alloc.provenance().ptrs().iter() {
let alloc_id = prov.alloc_id();
let offset = offset.bytes(); let offset = offset.bytes();
assert_eq!(offset as usize as u64, offset); assert_eq!(offset as usize as u64, offset);
let offset = offset as usize; let offset = offset as usize;
@ -313,7 +314,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
llvals.push(cx.scalar_to_backend( llvals.push(cx.scalar_to_backend(
InterpScalar::from_pointer( InterpScalar::from_pointer(
interpret::Pointer::new(alloc_id, Size::from_bytes(ptr_offset)), interpret::Pointer::new(prov, Size::from_bytes(ptr_offset)),
&cx.tcx, &cx.tcx,
), ),
abi::Scalar::Initialized { value: Primitive::Pointer(address_space), valid_range: WrappingRange::full(dl.pointer_size) }, abi::Scalar::Initialized { value: Primitive::Pointer(address_space), valid_range: WrappingRange::full(dl.pointer_size) },

View File

@ -22,12 +22,6 @@
use crate::callee::get_fn; use crate::callee::get_fn;
use crate::common::SignType; use crate::common::SignType;
#[derive(Clone)]
pub struct FuncSig<'gcc> {
pub params: Vec<Type<'gcc>>,
pub return_type: Type<'gcc>,
}
pub struct CodegenCx<'gcc, 'tcx> { pub struct CodegenCx<'gcc, 'tcx> {
pub check_overflow: bool, pub check_overflow: bool,
pub codegen_unit: &'tcx CodegenUnit<'tcx>, pub codegen_unit: &'tcx CodegenUnit<'tcx>,
@ -202,15 +196,16 @@ pub fn new(context: &'gcc Context<'gcc>, codegen_unit: &'tcx CodegenUnit<'tcx>,
let mut functions = FxHashMap::default(); let mut functions = FxHashMap::default();
let builtins = [ let builtins = [
"__builtin_unreachable", "abort", "__builtin_expect", "__builtin_add_overflow", "__builtin_mul_overflow", "__builtin_unreachable", "abort", "__builtin_expect", /*"__builtin_expect_with_probability",*/
"__builtin_saddll_overflow", /*"__builtin_sadd_overflow",*/ "__builtin_smulll_overflow", /*"__builtin_smul_overflow",*/ "__builtin_constant_p", "__builtin_add_overflow", "__builtin_mul_overflow", "__builtin_saddll_overflow",
/*"__builtin_sadd_overflow",*/ "__builtin_smulll_overflow", /*"__builtin_smul_overflow",*/
"__builtin_ssubll_overflow", /*"__builtin_ssub_overflow",*/ "__builtin_sub_overflow", "__builtin_uaddll_overflow", "__builtin_ssubll_overflow", /*"__builtin_ssub_overflow",*/ "__builtin_sub_overflow", "__builtin_uaddll_overflow",
"__builtin_uadd_overflow", "__builtin_umulll_overflow", "__builtin_umul_overflow", "__builtin_usubll_overflow", "__builtin_uadd_overflow", "__builtin_umulll_overflow", "__builtin_umul_overflow", "__builtin_usubll_overflow",
"__builtin_usub_overflow", "sqrtf", "sqrt", "__builtin_powif", "__builtin_powi", "sinf", "sin", "cosf", "cos", "__builtin_usub_overflow", "sqrtf", "sqrt", "__builtin_powif", "__builtin_powi", "sinf", "sin", "cosf", "cos",
"powf", "pow", "expf", "exp", "exp2f", "exp2", "logf", "log", "log10f", "log10", "log2f", "log2", "fmaf", "powf", "pow", "expf", "exp", "exp2f", "exp2", "logf", "log", "log10f", "log10", "log2f", "log2", "fmaf",
"fma", "fabsf", "fabs", "fminf", "fmin", "fmaxf", "fmax", "copysignf", "copysign", "floorf", "floor", "ceilf", "fma", "fabsf", "fabs", "fminf", "fmin", "fmaxf", "fmax", "copysignf", "copysign", "floorf", "floor", "ceilf",
"ceil", "truncf", "trunc", "rintf", "rint", "nearbyintf", "nearbyint", "roundf", "round", "ceil", "truncf", "trunc", "rintf", "rint", "nearbyintf", "nearbyint", "roundf", "round",
"__builtin_expect_with_probability",
]; ];
for builtin in builtins.iter() { for builtin in builtins.iter() {
@ -506,9 +501,9 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, 'tcx> {
#[inline] #[inline]
fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! { fn handle_layout_err(&self, err: LayoutError<'tcx>, span: Span, ty: Ty<'tcx>) -> ! {
if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err { if let LayoutError::SizeOverflow(_) | LayoutError::ReferencesError(_) = err {
self.sess().emit_fatal(respan(span, err.into_diagnostic())) self.tcx.dcx().emit_fatal(respan(span, err.into_diagnostic()))
} else { } else {
self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err }) self.tcx.dcx().emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
} }
} }
} }
@ -524,7 +519,7 @@ fn handle_fn_abi_err(
fn_abi_request: FnAbiRequest<'tcx>, fn_abi_request: FnAbiRequest<'tcx>,
) -> ! { ) -> ! {
if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err { if let FnAbiError::Layout(LayoutError::SizeOverflow(_)) = err {
self.sess().emit_fatal(respan(span, err)) self.tcx.dcx().emit_fatal(respan(span, err))
} else { } else {
match fn_abi_request { match fn_abi_request {
FnAbiRequest::OfFnPtr { sig, extra_args } => { FnAbiRequest::OfFnPtr { sig, extra_args } => {
@ -569,5 +564,6 @@ fn to_gcc_tls_mode(tls_model: TlsModel) -> gccjit::TlsModel {
TlsModel::LocalDynamic => gccjit::TlsModel::LocalDynamic, TlsModel::LocalDynamic => gccjit::TlsModel::LocalDynamic,
TlsModel::InitialExec => gccjit::TlsModel::InitialExec, TlsModel::InitialExec => gccjit::TlsModel::InitialExec,
TlsModel::LocalExec => gccjit::TlsModel::LocalExec, TlsModel::LocalExec => gccjit::TlsModel::LocalExec,
TlsModel::Emulated => gccjit::TlsModel::GlobalDynamic,
} }
} }

View File

@ -1,5 +1,6 @@
use rustc_errors::{ use rustc_errors::{
DiagnosticArgValue, DiagnosticBuilder, ErrorGuaranteed, Handler, IntoDiagnostic, IntoDiagnosticArg, DiagCtxt, DiagnosticArgValue, DiagnosticBuilder, EmissionGuarantee, IntoDiagnostic,
IntoDiagnosticArg, Level,
}; };
use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_macros::{Diagnostic, Subdiagnostic};
use rustc_span::Span; use rustc_span::Span;
@ -34,7 +35,7 @@ pub(crate) enum PossibleFeature<'a> {
struct ExitCode(Option<i32>); struct ExitCode(Option<i32>);
impl IntoDiagnosticArg for ExitCode { impl IntoDiagnosticArg for ExitCode {
fn into_diagnostic_arg(self) -> DiagnosticArgValue<'static> { fn into_diagnostic_arg(self) -> DiagnosticArgValue {
let ExitCode(exit_code) = self; let ExitCode(exit_code) = self;
match exit_code { match exit_code {
Some(t) => t.into_diagnostic_arg(), Some(t) => t.into_diagnostic_arg(),
@ -110,16 +111,20 @@ pub(crate) struct TargetFeatureDisableOrEnable<'a> {
#[help(codegen_gcc_missing_features)] #[help(codegen_gcc_missing_features)]
pub(crate) struct MissingFeatures; pub(crate) struct MissingFeatures;
impl IntoDiagnostic<'_, ErrorGuaranteed> for TargetFeatureDisableOrEnable<'_> { impl<G: EmissionGuarantee> IntoDiagnostic<'_, G> for TargetFeatureDisableOrEnable<'_> {
fn into_diagnostic(self, sess: &'_ Handler) -> DiagnosticBuilder<'_, ErrorGuaranteed> { fn into_diagnostic(self, dcx: &'_ DiagCtxt, level: Level) -> DiagnosticBuilder<'_, G> {
let mut diag = sess.struct_err(fluent::codegen_gcc_target_feature_disable_or_enable); let mut diag = DiagnosticBuilder::new(
dcx,
level,
fluent::codegen_gcc_target_feature_disable_or_enable
);
if let Some(span) = self.span { if let Some(span) = self.span {
diag.set_span(span); diag.span(span);
}; };
if let Some(missing_features) = self.missing_features { if let Some(missing_features) = self.missing_features {
diag.subdiagnostic(missing_features); diag.subdiagnostic(dcx, missing_features);
} }
diag.set_arg("features", self.features.join(", ")); diag.arg("features", self.features.join(", "));
diag diag
} }
} }

View File

@ -2,12 +2,10 @@
use gccjit::Context; use gccjit::Context;
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
use rustc_codegen_ssa::target_features::{
supported_target_features, tied_target_features, RUSTC_SPECIFIC_FEATURES,
};
use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::fx::FxHashMap;
use rustc_middle::bug; use rustc_middle::bug;
use rustc_session::Session; use rustc_session::Session;
use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES;
use crate::errors::{PossibleFeature, TargetFeatureDisableOrEnable, UnknownCTargetFeature, UnknownCTargetFeaturePrefix}; use crate::errors::{PossibleFeature, TargetFeatureDisableOrEnable, UnknownCTargetFeature, UnknownCTargetFeaturePrefix};
@ -44,7 +42,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
); );
// -Ctarget-features // -Ctarget-features
let supported_features = supported_target_features(sess); let supported_features = sess.target.supported_target_features();
let mut featsmap = FxHashMap::default(); let mut featsmap = FxHashMap::default();
let feats = sess.opts.cg.target_feature let feats = sess.opts.cg.target_feature
.split(',') .split(',')
@ -54,7 +52,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
Some(c @ ('+' | '-')) => c, Some(c @ ('+' | '-')) => c,
Some(_) => { Some(_) => {
if diagnostics { if diagnostics {
sess.emit_warning(UnknownCTargetFeaturePrefix { feature: s }); sess.dcx().emit_warn(UnknownCTargetFeaturePrefix { feature: s });
} }
return None; return None;
} }
@ -81,7 +79,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
else { else {
UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None } UnknownCTargetFeature { feature, rust_feature: PossibleFeature::None }
}; };
sess.emit_warning(unknown_feature); sess.dcx().emit_warn(unknown_feature);
} }
if diagnostics { if diagnostics {
@ -116,7 +114,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
if diagnostics { if diagnostics {
if let Some(f) = check_tied_features(sess, &featsmap) { if let Some(f) = check_tied_features(sess, &featsmap) {
sess.emit_err(TargetFeatureDisableOrEnable { sess.dcx().emit_err(TargetFeatureDisableOrEnable {
features: f, features: f,
span: None, span: None,
missing_features: None, missing_features: None,
@ -187,7 +185,7 @@ fn backend_feature_name(s: &str) -> Option<&str> {
// Given a map from target_features to whether they are enabled or disabled, // Given a map from target_features to whether they are enabled or disabled,
// ensure only valid combinations are allowed. // ensure only valid combinations are allowed.
pub fn check_tied_features(sess: &Session, features: &FxHashMap<&str, bool>) -> Option<&'static [&'static str]> { pub fn check_tied_features(sess: &Session, features: &FxHashMap<&str, bool>) -> Option<&'static [&'static str]> {
for tied in tied_target_features(sess) { for tied in sess.target.tied_target_features() {
// Tied features must be set to the same value, or not set at all // Tied features must be set to the same value, or not set at all
let mut tied_iter = tied.iter(); let mut tied_iter = tied.iter();
let enabled = features.get(tied_iter.next().unwrap()); let enabled = features.get(tied_iter.next().unwrap());

View File

@ -90,7 +90,7 @@ fn get_simple_intrinsic<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, name: Symbol) ->
} }
impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> { impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, args: &[OperandRef<'tcx, RValue<'gcc>>], llresult: RValue<'gcc>, span: Span) { fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, args: &[OperandRef<'tcx, RValue<'gcc>>], llresult: RValue<'gcc>, span: Span) -> Result<(), Instance<'tcx>> {
let tcx = self.tcx; let tcx = self.tcx;
let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all()); let callee_ty = instance.ty(tcx, ty::ParamEnv::reveal_all());
@ -123,6 +123,12 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
sym::unlikely => { sym::unlikely => {
self.expect(args[0].immediate(), false) self.expect(args[0].immediate(), false)
} }
sym::is_val_statically_known => {
let a = args[0].immediate();
let builtin = self.context.get_builtin_function("__builtin_constant_p");
let res = self.context.new_call(None, builtin, &[a]);
self.icmp(IntPredicate::IntEQ, res, self.const_i32(0))
}
kw::Try => { kw::Try => {
try_intrinsic( try_intrinsic(
self, self,
@ -131,7 +137,7 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
args[2].immediate(), args[2].immediate(),
llresult, llresult,
); );
return; return Ok(());
} }
sym::breakpoint => { sym::breakpoint => {
unimplemented!(); unimplemented!();
@ -160,12 +166,12 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
sym::volatile_store => { sym::volatile_store => {
let dst = args[0].deref(self.cx()); let dst = args[0].deref(self.cx());
args[1].val.volatile_store(self, dst); args[1].val.volatile_store(self, dst);
return; return Ok(());
} }
sym::unaligned_volatile_store => { sym::unaligned_volatile_store => {
let dst = args[0].deref(self.cx()); let dst = args[0].deref(self.cx());
args[1].val.unaligned_volatile_store(self, dst); args[1].val.unaligned_volatile_store(self, dst);
return; return Ok(());
} }
sym::prefetch_read_data sym::prefetch_read_data
| sym::prefetch_write_data | sym::prefetch_write_data
@ -262,8 +268,8 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
_ => bug!(), _ => bug!(),
}, },
None => { None => {
tcx.sess.emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty }); tcx.dcx().emit_err(InvalidMonomorphization::BasicIntegerType { span, name, ty });
return; return Ok(());
} }
} }
} }
@ -333,7 +339,7 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
extended_asm.set_volatile_flag(true); extended_asm.set_volatile_flag(true);
// We have copied the value to `result` already. // We have copied the value to `result` already.
return; return Ok(());
} }
sym::ptr_mask => { sym::ptr_mask => {
@ -351,11 +357,12 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
_ if name_str.starts_with("simd_") => { _ if name_str.starts_with("simd_") => {
match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) { match generic_simd_intrinsic(self, name, callee_ty, args, ret_ty, llret_ty, span) {
Ok(llval) => llval, Ok(llval) => llval,
Err(()) => return, Err(()) => return Ok(()),
} }
} }
_ => bug!("unknown intrinsic '{}'", name), // Fall back to default body
_ => return Err(Instance::new(instance.def_id(), instance.args)),
}; };
if !fn_abi.ret.is_ignore() { if !fn_abi.ret.is_ignore() {
@ -370,6 +377,7 @@ fn codegen_intrinsic_call(&mut self, instance: Instance<'tcx>, fn_abi: &FnAbi<'t
.store(self, result); .store(self, result);
} }
} }
Ok(())
} }
fn abort(&mut self) { fn abort(&mut self) {

View File

@ -38,7 +38,7 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
// macros for error handling: // macros for error handling:
macro_rules! return_error { macro_rules! return_error {
($err:expr) => {{ ($err:expr) => {{
bx.sess().emit_err($err); bx.tcx.dcx().emit_err($err);
return Err(()); return Err(());
}}; }};
} }
@ -583,7 +583,7 @@ fn simd_simple_float_intrinsic<'gcc, 'tcx>(
) -> Result<RValue<'gcc>, ()> { ) -> Result<RValue<'gcc>, ()> {
macro_rules! return_error { macro_rules! return_error {
($err:expr) => {{ ($err:expr) => {{
bx.sess().emit_err($err); bx.tcx.dcx().emit_err($err);
return Err(()); return Err(());
}}; }};
} }

View File

@ -28,8 +28,6 @@
#![recursion_limit="256"] #![recursion_limit="256"]
#![warn(rust_2018_idioms)] #![warn(rust_2018_idioms)]
#![warn(unused_lifetimes)] #![warn(unused_lifetimes)]
#![deny(rustc::untranslatable_diagnostic)]
#![deny(rustc::diagnostic_outside_of_impl)]
#![deny(clippy::pattern_type_mismatch)] #![deny(clippy::pattern_type_mismatch)]
extern crate rustc_apfloat; extern crate rustc_apfloat;
@ -99,12 +97,10 @@
use rustc_codegen_ssa::base::codegen_crate; use rustc_codegen_ssa::base::codegen_crate;
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn}; use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput, ModuleConfig, TargetMachineFactoryFn};
use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule}; use rustc_codegen_ssa::back::lto::{LtoModuleCodegen, SerializedModule, ThinModule};
use rustc_codegen_ssa::target_features::supported_target_features;
use rustc_data_structures::fx::FxIndexMap; use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::sync::IntoDynSyncSend; use rustc_data_structures::sync::IntoDynSyncSend;
use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods}; use rustc_codegen_ssa::traits::{CodegenBackend, ExtraBackendMethods, ThinBufferMethods, WriteBackendMethods};
use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, SubdiagnosticMessage}; use rustc_errors::{ErrorGuaranteed, DiagCtxt};
use rustc_fluent_macro::fluent_messages;
use rustc_metadata::EncodedMetadata; use rustc_metadata::EncodedMetadata;
use rustc_middle::dep_graph::{WorkProduct, WorkProductId}; use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
use rustc_middle::util::Providers; use rustc_middle::util::Providers;
@ -118,7 +114,7 @@
use crate::back::lto::ModuleBuffer; use crate::back::lto::ModuleBuffer;
use crate::gcc_util::target_cpu; use crate::gcc_util::target_cpu;
fluent_messages! { "../messages.ftl" } rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
pub struct PrintOnPanic<F: Fn() -> String>(pub F); pub struct PrintOnPanic<F: Fn() -> String>(pub F);
@ -195,7 +191,7 @@ fn init(&self, sess: &Session) {
#[cfg(feature="master")] #[cfg(feature="master")]
gccjit::set_global_personality_function_name(b"rust_eh_personality\0"); gccjit::set_global_personality_function_name(b"rust_eh_personality\0");
if sess.lto() == Lto::Thin { if sess.lto() == Lto::Thin {
sess.emit_warning(LTONotSupported {}); sess.dcx().emit_warn(LTONotSupported {});
} }
#[cfg(not(feature="master"))] #[cfg(not(feature="master"))]
@ -223,13 +219,11 @@ fn codegen_crate<'tcx>(&self, tcx: TyCtxt<'tcx>, metadata: EncodedMetadata, need
Box::new(res) Box::new(res)
} }
fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> Result<(CodegenResults, FxIndexMap<WorkProductId, WorkProduct>), ErrorGuaranteed> { fn join_codegen(&self, ongoing_codegen: Box<dyn Any>, sess: &Session, _outputs: &OutputFilenames) -> (CodegenResults, FxIndexMap<WorkProductId, WorkProduct>) {
let (codegen_results, work_products) = ongoing_codegen ongoing_codegen
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>() .downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>") .expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
.join(sess); .join(sess)
Ok((codegen_results, work_products))
} }
fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> { fn link(&self, sess: &Session, codegen_results: CodegenResults, outputs: &OutputFilenames) -> Result<(), ErrorGuaranteed> {
@ -335,7 +329,7 @@ fn print_statistics(&self) {
unimplemented!() unimplemented!()
} }
unsafe fn optimize(_cgcx: &CodegenContext<Self>, _diag_handler: &Handler, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> { unsafe fn optimize(_cgcx: &CodegenContext<Self>, _dcx: &DiagCtxt, module: &ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<(), FatalError> {
module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level)); module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level));
Ok(()) Ok(())
} }
@ -349,8 +343,8 @@ unsafe fn optimize_thin(_cgcx: &CodegenContext<Self>, _thin: ThinModule<Self>) -
unimplemented!(); unimplemented!();
} }
unsafe fn codegen(cgcx: &CodegenContext<Self>, diag_handler: &Handler, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> { unsafe fn codegen(cgcx: &CodegenContext<Self>, dcx: &DiagCtxt, module: ModuleCodegen<Self::Module>, config: &ModuleConfig) -> Result<CompiledModule, FatalError> {
back::write::codegen(cgcx, diag_handler, module, config) back::write::codegen(cgcx, dcx, module, config)
} }
fn prepare_thin(_module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) { fn prepare_thin(_module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
@ -361,8 +355,8 @@ fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::Modu
unimplemented!(); unimplemented!();
} }
fn run_link(cgcx: &CodegenContext<Self>, diag_handler: &Handler, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> { fn run_link(cgcx: &CodegenContext<Self>, dcx: &DiagCtxt, modules: Vec<ModuleCodegen<Self::Module>>) -> Result<ModuleCodegen<Self::Module>, FatalError> {
back::write::link(cgcx, diag_handler, modules) back::write::link(cgcx, dcx, modules)
} }
} }
@ -401,7 +395,9 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
} }
pub fn target_features(sess: &Session, allow_unstable: bool, target_info: &LockedTargetInfo) -> Vec<Symbol> { pub fn target_features(sess: &Session, allow_unstable: bool, target_info: &LockedTargetInfo) -> Vec<Symbol> {
supported_target_features(sess) sess
.target
.supported_target_features()
.iter() .iter()
.filter_map( .filter_map(
|&(feature, gate)| { |&(feature, gate)| {
@ -411,7 +407,7 @@ pub fn target_features(sess: &Session, allow_unstable: bool, target_info: &Locke
.filter(|_feature| { .filter(|_feature| {
target_info.cpu_supports(_feature) target_info.cpu_supports(_feature)
/* /*
adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512ifma, adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma,
avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq, avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm, bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves

View File

@ -87,7 +87,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
// FIXME(eddyb) producing readable type names for trait objects can result // FIXME(eddyb) producing readable type names for trait objects can result
// in problematically distinct types due to HRTB and subtyping (see #47638). // in problematically distinct types due to HRTB and subtyping (see #47638).
// ty::Dynamic(..) | // ty::Dynamic(..) |
ty::Adt(..) | ty::Closure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str ty::Adt(..) | ty::Closure(..) | ty::CoroutineClosure(..) | ty::Foreign(..) | ty::Coroutine(..) | ty::Str
if !cx.sess().fewer_names() => if !cx.sess().fewer_names() =>
{ {
let mut name = with_no_trimmed_paths!(layout.ty.to_string()); let mut name = with_no_trimmed_paths!(layout.ty.to_string());
@ -98,7 +98,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
write!(&mut name, "::{}", def.variant(index).name).unwrap(); write!(&mut name, "::{}", def.variant(index).name).unwrap();
} }
} }
if let (&ty::Coroutine(_, _, _), &Variants::Single { index }) = if let (&ty::Coroutine(_, _), &Variants::Single { index }) =
(layout.ty.kind(), &layout.variants) (layout.ty.kind(), &layout.variants)
{ {
write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap(); write!(&mut name, "::{}", ty::CoroutineArgs::variant_name(index)).unwrap();

View File

@ -1,6 +1,6 @@
tests/ui/lint/unsafe_code/forge_unsafe_block.rs tests/ui/lint/unsafe_code/forge_unsafe_block.rs
tests/ui/lint/unused-qualification-in-derive-expansion.rs tests/ui/lint/unused-qualification-in-derive-expansion.rs
tests/ui/macro-quote-test.rs tests/ui/macros/macro-quote-test.rs
tests/ui/macros/proc_macro.rs tests/ui/macros/proc_macro.rs
tests/ui/panic-runtime/lto-unwind.rs tests/ui/panic-runtime/lto-unwind.rs
tests/ui/resolve/derive-macro-1.rs tests/ui/resolve/derive-macro-1.rs
@ -21,3 +21,17 @@ tests/ui/fmt/format-args-capture-issue-106408.rs
tests/ui/fmt/indoc-issue-106408.rs tests/ui/fmt/indoc-issue-106408.rs
tests/ui/hygiene/issue-77523-def-site-async-await.rs tests/ui/hygiene/issue-77523-def-site-async-await.rs
tests/ui/inherent-impls-overlap-check/no-overlap.rs tests/ui/inherent-impls-overlap-check/no-overlap.rs
tests/ui/annotate-snippet/multispan.rs
tests/ui/enum-discriminant/issue-46519.rs
tests/ui/issues/issue-45731.rs
tests/ui/lint/test-allow-dead-extern-static-no-warning.rs
tests/ui/macros/macro-comma-behavior-rpass.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/assert-with-custom-errors-does-not-create-unnecessary-code.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/feature-gate-generic_assert.rs
tests/ui/macros/stringify.rs
tests/ui/panics/test-panic.rs
tests/ui/panics/test-should-fail-bad-message.rs
tests/ui/panics/test-should-panic-bad-message.rs
tests/ui/panics/test-should-panic-no-message.rs
tests/ui/reexport-test-harness-main.rs
tests/ui/rfcs/rfc-1937-termination-trait/termination-trait-in-test.rs

View File

@ -69,3 +69,42 @@ tests/ui/async-await/deep-futures-are-freeze.rs
tests/ui/closures/capture-unsized-by-ref.rs tests/ui/closures/capture-unsized-by-ref.rs
tests/ui/coroutine/resume-after-return.rs tests/ui/coroutine/resume-after-return.rs
tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs
tests/ui/limits/issue-17913.rs
tests/ui/limits/issue-55878.rs
tests/ui/linkage-attr/common-linkage-non-zero-init.rs
tests/ui/linkage-attr/linkage-detect-extern-generated-name-collision.rs
tests/ui/numbers-arithmetic/divide-by-zero.rs
tests/ui/numbers-arithmetic/mod-zero.rs
tests/ui/numbers-arithmetic/overflowing-neg-nonzero.rs
tests/ui/numbers-arithmetic/overflowing-neg.rs
tests/ui/optimization-remark.rs
tests/ui/panic-handler/panic-handler-std.rs
tests/ui/panic-runtime/abort-link-to-unwind-dylib.rs
tests/ui/panic-runtime/need-unwind-got-abort.rs
tests/ui/panics/issue-47429-short-backtraces.rs
tests/ui/panics/panic-in-cleanup.rs
tests/ui/panics/panic-in-ffi.rs
tests/ui/panics/runtime-switch.rs
tests/ui/panics/short-ice-remove-middle-frames-2.rs
tests/ui/panics/short-ice-remove-middle-frames.rs
tests/ui/precondition-checks/out-of-bounds-get-unchecked.rs
tests/ui/simd/masked-load-store.rs
tests/ui/simd/repr_packed.rs
tests/ui/type_length_limit.rs
tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs
tests/ui/async-await/issues/issue-65419/issue-65419-coroutine-resume-after-completion.rs
tests/ui/c-variadic/issue-86053-1.rs
tests/ui/const-ptr/out_of_bounds_read.rs
tests/ui/consts/const_unsafe_unreachable_ub.rs
tests/ui/consts/miri_unleashed/drop.rs
tests/ui/consts/timeout.rs
tests/ui/consts/try-operator.rs
tests/ui/coroutine/coroutine-resume-after-panic.rs
tests/ui/coroutine/unwind-abort-mix.rs
tests/ui/duplicate/dupe-symbols-7.rs
tests/ui/duplicate/dupe-symbols-8.rs
tests/ui/hygiene/panic-location.rs
tests/ui/invalid/issue-114435-layout-type-err.rs
tests/ui/invalid-compile-flags/invalid-llvm-passes.rs
tests/ui/lto/issue-105637.rs
tests/ui/lto/lto-duplicate-symbols.rs

View File

@ -42,3 +42,7 @@ tests/ui/codegen/issue-79865-llvm-miscompile.rs
tests/ui/std-backtrace.rs tests/ui/std-backtrace.rs
tests/ui/mir/alignment/packed.rs tests/ui/mir/alignment/packed.rs
tests/ui/intrinsics/intrinsics-integer.rs tests/ui/intrinsics/intrinsics-integer.rs
tests/ui/asm/x86_64/evex512-implicit-feature.rs
tests/ui/packed/dyn-trait.rs
tests/ui/packed/issue-118537-field-offset-ice.rs
tests/ui/stable-mir-print/basic_function.rs

View File

@ -61,9 +61,6 @@ mod libc {
#[lang = "structural_peq"] #[lang = "structural_peq"]
pub trait StructuralPartialEq {} pub trait StructuralPartialEq {}
#[lang = "structural_teq"]
pub trait StructuralEq {}
#[lang = "drop_in_place"] #[lang = "drop_in_place"]
#[allow(unconditional_recursion)] #[allow(unconditional_recursion)]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) { pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {