Merge pull request #350 from rust-lang/sync_from_rust_2023_10_08
Sync from rust 2023/10/08
This commit is contained in:
commit
11a0cceab9
27 changed files with 77 additions and 69 deletions
|
@ -12,6 +12,7 @@
|
||||||
target_arch = "mips",
|
target_arch = "mips",
|
||||||
target_arch = "mips32r6",
|
target_arch = "mips32r6",
|
||||||
target_arch = "powerpc",
|
target_arch = "powerpc",
|
||||||
|
target_arch = "csky",
|
||||||
target_arch = "powerpc64"))]
|
target_arch = "powerpc64"))]
|
||||||
const MIN_ALIGN: usize = 8;
|
const MIN_ALIGN: usize = 8;
|
||||||
#[cfg(any(target_arch = "x86_64",
|
#[cfg(any(target_arch = "x86_64",
|
||||||
|
|
|
@ -429,6 +429,15 @@ fn panic_cannot_unwind() -> ! {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[lang = "panic_in_cleanup"]
|
||||||
|
#[rustc_nounwind]
|
||||||
|
fn panic_in_cleanup() -> ! {
|
||||||
|
unsafe {
|
||||||
|
libc::printf("panic in a destructor during cleanup\n\0" as *const str as *const i8);
|
||||||
|
intrinsics::abort();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[lang = "panic_bounds_check"]
|
#[lang = "panic_bounds_check"]
|
||||||
#[track_caller]
|
#[track_caller]
|
||||||
fn panic_bounds_check(index: usize, len: usize) -> ! {
|
fn panic_bounds_check(index: usize, len: usize) -> ! {
|
||||||
|
|
|
@ -68,3 +68,6 @@ tests/ui/lto/thin-lto-global-allocator.rs
|
||||||
tests/ui/lto/msvc-imp-present.rs
|
tests/ui/lto/msvc-imp-present.rs
|
||||||
tests/ui/lto/lto-thin-rustc-loads-linker-plugin.rs
|
tests/ui/lto/lto-thin-rustc-loads-linker-plugin.rs
|
||||||
tests/ui/lto/all-crates.rs
|
tests/ui/lto/all-crates.rs
|
||||||
|
tests/ui/async-await/deep-futures-are-freeze.rs
|
||||||
|
tests/ui/closures/capture-unsized-by-ref.rs
|
||||||
|
tests/ui/generator/resume-after-return.rs
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
[toolchain]
|
[toolchain]
|
||||||
channel = "nightly-2023-08-12"
|
channel = "nightly-2023-10-08"
|
||||||
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]
|
||||||
|
|
16
src/abi.rs
16
src/abi.rs
|
@ -115,7 +115,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
||||||
match self.ret.mode {
|
match self.ret.mode {
|
||||||
PassMode::Ignore => cx.type_void(),
|
PassMode::Ignore => cx.type_void(),
|
||||||
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
|
PassMode::Direct(_) | PassMode::Pair(..) => self.ret.layout.immediate_gcc_type(cx),
|
||||||
PassMode::Cast(ref cast, _) => cast.gcc_type(cx),
|
PassMode::Cast { ref cast, .. } => cast.gcc_type(cx),
|
||||||
PassMode::Indirect { .. } => {
|
PassMode::Indirect { .. } => {
|
||||||
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
|
argument_tys.push(cx.type_ptr_to(self.ret.memory_ty(cx)));
|
||||||
cx.type_void()
|
cx.type_void()
|
||||||
|
@ -141,11 +141,11 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
||||||
let arg_ty = match arg.mode {
|
let arg_ty = match arg.mode {
|
||||||
PassMode::Ignore => continue,
|
PassMode::Ignore => continue,
|
||||||
PassMode::Pair(a, b) => {
|
PassMode::Pair(a, b) => {
|
||||||
argument_tys.push(apply_attrs(arg.layout.scalar_pair_element_gcc_type(cx, 0, true), &a));
|
argument_tys.push(apply_attrs(arg.layout.scalar_pair_element_gcc_type(cx, 0), &a));
|
||||||
argument_tys.push(apply_attrs(arg.layout.scalar_pair_element_gcc_type(cx, 1, true), &b));
|
argument_tys.push(apply_attrs(arg.layout.scalar_pair_element_gcc_type(cx, 1), &b));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
PassMode::Cast(ref cast, pad_i32) => {
|
PassMode::Cast { ref cast, pad_i32 } => {
|
||||||
// add padding
|
// add padding
|
||||||
if pad_i32 {
|
if pad_i32 {
|
||||||
argument_tys.push(Reg::i32().gcc_type(cx));
|
argument_tys.push(Reg::i32().gcc_type(cx));
|
||||||
|
@ -153,18 +153,18 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
|
||||||
let ty = cast.gcc_type(cx);
|
let ty = cast.gcc_type(cx);
|
||||||
apply_attrs(ty, &cast.attrs)
|
apply_attrs(ty, &cast.attrs)
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs: _, extra_attrs: None, on_stack: true } => {
|
PassMode::Indirect { attrs: _, meta_attrs: None, on_stack: true } => {
|
||||||
// This is a "byval" argument, so we don't apply the `restrict` attribute on it.
|
// This is a "byval" argument, so we don't apply the `restrict` attribute on it.
|
||||||
on_stack_param_indices.insert(argument_tys.len());
|
on_stack_param_indices.insert(argument_tys.len());
|
||||||
arg.memory_ty(cx)
|
arg.memory_ty(cx)
|
||||||
},
|
},
|
||||||
PassMode::Direct(attrs) => apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs),
|
PassMode::Direct(attrs) => apply_attrs(arg.layout.immediate_gcc_type(cx), &attrs),
|
||||||
PassMode::Indirect { attrs, extra_attrs: None, on_stack: false } => {
|
PassMode::Indirect { attrs, meta_attrs: None, on_stack: false } => {
|
||||||
apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs)
|
apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs)
|
||||||
}
|
}
|
||||||
PassMode::Indirect { attrs, extra_attrs: Some(extra_attrs), on_stack } => {
|
PassMode::Indirect { attrs, meta_attrs: Some(meta_attrs), on_stack } => {
|
||||||
assert!(!on_stack);
|
assert!(!on_stack);
|
||||||
apply_attrs(apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs), &extra_attrs)
|
apply_attrs(apply_attrs(cx.type_ptr_to(arg.memory_ty(cx)), &attrs), &meta_attrs)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
argument_tys.push(arg_ty);
|
argument_tys.push(arg_ty);
|
||||||
|
|
|
@ -107,7 +107,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()
|
||||||
.create_err(UnwindingInlineAsm { span: span[0] })
|
.create_err(UnwindingInlineAsm { span: span[0] })
|
||||||
|
@ -173,7 +173,7 @@ impl<'a, 'gcc, 'tcx> AsmBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
let is_target_supported = reg.reg_class().supported_types(asm_arch).iter()
|
let is_target_supported = reg.reg_class().supported_types(asm_arch).iter()
|
||||||
.any(|&(_, feature)| {
|
.any(|&(_, feature)| {
|
||||||
if let Some(feature) = feature {
|
if let Some(feature) = feature {
|
||||||
self.tcx.sess.target_features.contains(&feature)
|
self.tcx.asm_target_features(instance.def_id()).contains(&feature)
|
||||||
} else {
|
} else {
|
||||||
true // Register class is unconditionally supported
|
true // Register class is unconditionally supported
|
||||||
}
|
}
|
||||||
|
@ -593,6 +593,8 @@ fn reg_to_gcc(reg: InlineAsmRegOrRegClass) -> ConstraintOrRegister {
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => "r",
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => "r",
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => "a",
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => "a",
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => "d",
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => "d",
|
||||||
|
InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::reg) => "r",
|
||||||
|
InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::freg) => "f",
|
||||||
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => "d", // more specific than "r"
|
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => "d", // more specific than "r"
|
||||||
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => "f",
|
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => "f",
|
||||||
InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => "r",
|
InlineAsmRegClass::Msp430(Msp430InlineAsmRegClass::reg) => "r",
|
||||||
|
@ -669,6 +671,8 @@ fn dummy_output_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, reg: InlineAsmRegCl
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => cx.type_i32(),
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg) => cx.type_i32(),
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => cx.type_i32(),
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_addr) => cx.type_i32(),
|
||||||
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => cx.type_i32(),
|
InlineAsmRegClass::M68k(M68kInlineAsmRegClass::reg_data) => cx.type_i32(),
|
||||||
|
InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::reg) => cx.type_i32(),
|
||||||
|
InlineAsmRegClass::CSKY(CSKYInlineAsmRegClass::freg) => cx.type_f32(),
|
||||||
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(),
|
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::reg) => cx.type_i32(),
|
||||||
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => cx.type_f32(),
|
InlineAsmRegClass::Mips(MipsInlineAsmRegClass::freg) => cx.type_f32(),
|
||||||
InlineAsmRegClass::Msp430(_) => unimplemented!(),
|
InlineAsmRegClass::Msp430(_) => unimplemented!(),
|
||||||
|
@ -856,6 +860,7 @@ fn modifier_to_gcc(arch: InlineAsmArch, reg: InlineAsmRegClass, modifier: Option
|
||||||
InlineAsmRegClass::S390x(_) => None,
|
InlineAsmRegClass::S390x(_) => None,
|
||||||
InlineAsmRegClass::Msp430(_) => None,
|
InlineAsmRegClass::Msp430(_) => None,
|
||||||
InlineAsmRegClass::M68k(_) => None,
|
InlineAsmRegClass::M68k(_) => None,
|
||||||
|
InlineAsmRegClass::CSKY(_) => None,
|
||||||
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
|
InlineAsmRegClass::SpirV(SpirVInlineAsmRegClass::reg) => {
|
||||||
bug!("LLVM backend does not support SPIR-V")
|
bug!("LLVM backend does not support SPIR-V")
|
||||||
}
|
}
|
||||||
|
|
|
@ -656,7 +656,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_sadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_sadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
a + b
|
self.gcc_add(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_uadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_uadd(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
|
@ -664,7 +664,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_ssub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_ssub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
a - b
|
self.gcc_sub(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_usub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_usub(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
|
@ -673,11 +673,11 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_smul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_smul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
a * b
|
self.gcc_mul(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn unchecked_umul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
fn unchecked_umul(&mut self, a: RValue<'gcc>, b: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
a * b
|
self.gcc_mul(a, b)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
|
fn fadd_fast(&mut self, lhs: RValue<'gcc>, rhs: RValue<'gcc>) -> RValue<'gcc> {
|
||||||
|
@ -814,7 +814,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
|
|
||||||
let mut load = |i, scalar: &abi::Scalar, align| {
|
let mut load = |i, scalar: &abi::Scalar, align| {
|
||||||
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
|
let llptr = self.struct_gep(pair_type, place.llval, i as u64);
|
||||||
let llty = place.layout.scalar_pair_element_gcc_type(self, i, false);
|
let llty = place.layout.scalar_pair_element_gcc_type(self, i);
|
||||||
let load = self.load(llty, llptr, align);
|
let load = self.load(llty, llptr, align);
|
||||||
scalar_load_metadata(self, load, scalar);
|
scalar_load_metadata(self, load, scalar);
|
||||||
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
|
if scalar.is_bool() { self.trunc(load, self.type_i1()) } else { load }
|
||||||
|
@ -1421,7 +1421,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
self.cx
|
self.cx
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_not_inline(&mut self, _llret: RValue<'gcc>) {
|
fn apply_attrs_to_cleanup_callsite(&mut self, _llret: RValue<'gcc>) {
|
||||||
// FIXME(bjorn3): implement
|
// FIXME(bjorn3): implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -100,7 +100,7 @@ pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>)
|
||||||
// whether we are sharing generics or not. The important thing here is
|
// whether we are sharing generics or not. The important thing here is
|
||||||
// that the visibility we apply to the declaration is the same one that
|
// that the visibility we apply to the declaration is the same one that
|
||||||
// has been applied to the definition (wherever that definition may be).
|
// has been applied to the definition (wherever that definition may be).
|
||||||
let is_generic = instance.args.non_erasable_generics().next().is_some();
|
let is_generic = instance.args.non_erasable_generics(tcx, instance.def_id()).next().is_some();
|
||||||
|
|
||||||
if is_generic {
|
if is_generic {
|
||||||
// This is a monomorphization. Its expected visibility depends
|
// This is a monomorphization. Its expected visibility depends
|
||||||
|
|
|
@ -7,6 +7,7 @@ use rustc_codegen_ssa::traits::{
|
||||||
BaseTypeMethods,
|
BaseTypeMethods,
|
||||||
MiscMethods,
|
MiscMethods,
|
||||||
};
|
};
|
||||||
|
use rustc_codegen_ssa::errors as ssa_errors;
|
||||||
use rustc_data_structures::base_n;
|
use rustc_data_structures::base_n;
|
||||||
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
|
||||||
use rustc_middle::span_bug;
|
use rustc_middle::span_bug;
|
||||||
|
@ -479,7 +480,7 @@ impl<'gcc, 'tcx> LayoutOfHelpers<'tcx> for CodegenCx<'gcc, '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.sess().emit_fatal(respan(span, err.into_diagnostic()))
|
||||||
} else {
|
} else {
|
||||||
span_bug!(span, "failed to get layout for `{}`: {}", ty, err)
|
self.tcx.sess.emit_fatal(ssa_errors::FailedToGetLayout { span, ty, err })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||||
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
|
||||||
_llfn: RValue<'gcc>,
|
_llfn: RValue<'gcc>,
|
||||||
_mir: &mir::Body<'tcx>,
|
_mir: &mir::Body<'tcx>,
|
||||||
) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
|
) -> Option<FunctionDebugContext<'tcx, Self::DIScope, Self::DILocation>> {
|
||||||
// TODO(antoyo)
|
// TODO(antoyo)
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
sym::volatile_load | sym::unaligned_volatile_load => {
|
sym::volatile_load | sym::unaligned_volatile_load => {
|
||||||
let tp_ty = fn_args.type_at(0);
|
let tp_ty = fn_args.type_at(0);
|
||||||
let mut ptr = args[0].immediate();
|
let mut ptr = args[0].immediate();
|
||||||
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
|
if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode {
|
||||||
ptr = self.pointercast(ptr, self.type_ptr_to(ty.gcc_type(self)));
|
ptr = self.pointercast(ptr, self.type_ptr_to(ty.gcc_type(self)));
|
||||||
}
|
}
|
||||||
let load = self.volatile_load(ptr.get_type(), ptr);
|
let load = self.volatile_load(ptr.get_type(), ptr);
|
||||||
|
@ -353,7 +353,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if !fn_abi.ret.is_ignore() {
|
if !fn_abi.ret.is_ignore() {
|
||||||
if let PassMode::Cast(ty, _) = &fn_abi.ret.mode {
|
if let PassMode::Cast { cast: ty, .. } = &fn_abi.ret.mode {
|
||||||
let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
|
let ptr_llty = self.type_ptr_to(ty.gcc_type(self));
|
||||||
let ptr = self.pointercast(result.llval, ptr_llty);
|
let ptr = self.pointercast(result.llval, ptr_llty);
|
||||||
self.store(llval, ptr, result.align);
|
self.store(llval, ptr, result.align);
|
||||||
|
@ -449,7 +449,7 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
|
||||||
else if self.is_unsized_indirect() {
|
else if self.is_unsized_indirect() {
|
||||||
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
|
bug!("unsized `ArgAbi` must be handled through `store_fn_arg`");
|
||||||
}
|
}
|
||||||
else if let PassMode::Cast(ref cast, _) = self.mode {
|
else if let PassMode::Cast { ref cast, .. } = self.mode {
|
||||||
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
|
// FIXME(eddyb): Figure out when the simpler Store is safe, clang
|
||||||
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
|
// uses it for i16 -> {i8, i8}, but not for i24 -> {i8, i8, i8}.
|
||||||
let can_store_through_cast_ptr = false;
|
let can_store_through_cast_ptr = false;
|
||||||
|
@ -511,10 +511,10 @@ impl<'gcc, 'tcx> ArgAbiExt<'gcc, 'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
|
||||||
PassMode::Pair(..) => {
|
PassMode::Pair(..) => {
|
||||||
OperandValue::Pair(next(), next()).store(bx, dst);
|
OperandValue::Pair(next(), next()).store(bx, dst);
|
||||||
},
|
},
|
||||||
PassMode::Indirect { extra_attrs: Some(_), .. } => {
|
PassMode::Indirect { meta_attrs: Some(_), .. } => {
|
||||||
OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
|
OperandValue::Ref(next(), Some(next()), self.layout.align.abi).store(bx, dst);
|
||||||
},
|
},
|
||||||
PassMode::Direct(_) | PassMode::Indirect { extra_attrs: None, .. } | PassMode::Cast(..) => {
|
PassMode::Direct(_) | PassMode::Indirect { meta_attrs: None, .. } | PassMode::Cast { .. } => {
|
||||||
let next_arg = next();
|
let next_arg = next();
|
||||||
self.store(bx, next_arg, dst);
|
self.store(bx, next_arg, dst);
|
||||||
},
|
},
|
||||||
|
|
|
@ -98,7 +98,7 @@ use rustc_errors::{DiagnosticMessage, ErrorGuaranteed, Handler, SubdiagnosticMes
|
||||||
use rustc_fluent_macro::fluent_messages;
|
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::query::Providers;
|
use rustc_middle::util::Providers;
|
||||||
use rustc_middle::ty::TyCtxt;
|
use rustc_middle::ty::TyCtxt;
|
||||||
use rustc_session::config::{Lto, OptLevel, OutputFilenames};
|
use rustc_session::config::{Lto, OptLevel, OutputFilenames};
|
||||||
use rustc_session::Session;
|
use rustc_session::Session;
|
||||||
|
|
|
@ -4,7 +4,7 @@ use gccjit::{Struct, Type};
|
||||||
use crate::rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods};
|
use crate::rustc_codegen_ssa::traits::{BaseTypeMethods, DerivedTypeMethods, LayoutTypeMethods};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
|
use rustc_middle::ty::{self, Ty, TypeVisitableExt};
|
||||||
use rustc_middle::ty::layout::{FnAbiOf, LayoutOf, TyAndLayout};
|
use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
|
||||||
use rustc_middle::ty::print::with_no_trimmed_paths;
|
use rustc_middle::ty::print::with_no_trimmed_paths;
|
||||||
use rustc_target::abi::{self, Abi, Align, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
|
use rustc_target::abi::{self, Abi, Align, F32, F64, FieldsShape, Int, Integer, Pointer, PointeeInfo, Size, TyAbiInterface, Variants};
|
||||||
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
use rustc_target::abi::call::{CastTarget, FnAbi, Reg};
|
||||||
|
@ -74,8 +74,8 @@ fn uncached_gcc_type<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, layout: TyAndLayout
|
||||||
Abi::ScalarPair(..) => {
|
Abi::ScalarPair(..) => {
|
||||||
return cx.type_struct(
|
return cx.type_struct(
|
||||||
&[
|
&[
|
||||||
layout.scalar_pair_element_gcc_type(cx, 0, false),
|
layout.scalar_pair_element_gcc_type(cx, 0),
|
||||||
layout.scalar_pair_element_gcc_type(cx, 1, false),
|
layout.scalar_pair_element_gcc_type(cx, 1),
|
||||||
],
|
],
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
|
@ -150,7 +150,7 @@ pub trait LayoutGccExt<'tcx> {
|
||||||
fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
|
fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
|
||||||
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
|
fn immediate_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc>;
|
||||||
fn scalar_gcc_type_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, scalar: &abi::Scalar, offset: Size) -> Type<'gcc>;
|
fn scalar_gcc_type_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, scalar: &abi::Scalar, offset: Size) -> Type<'gcc>;
|
||||||
fn scalar_pair_element_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, index: usize, immediate: bool) -> Type<'gcc>;
|
fn scalar_pair_element_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, index: usize) -> Type<'gcc>;
|
||||||
fn gcc_field_index(&self, index: usize) -> u64;
|
fn gcc_field_index(&self, index: usize) -> u64;
|
||||||
fn pointee_info_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, offset: Size) -> Option<PointeeInfo>;
|
fn pointee_info_at<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, offset: Size) -> Option<PointeeInfo>;
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
||||||
/// of that field's type - this is useful for taking the address of
|
/// of that field's type - this is useful for taking the address of
|
||||||
/// that field and ensuring the struct has the right alignment.
|
/// that field and ensuring the struct has the right alignment.
|
||||||
fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
|
fn gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>) -> Type<'gcc> {
|
||||||
|
use crate::rustc_middle::ty::layout::FnAbiOf;
|
||||||
|
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
||||||
|
// In other words, this should generally not look at the type at all, but only at the
|
||||||
|
// layout.
|
||||||
if let Abi::Scalar(ref scalar) = self.abi {
|
if let Abi::Scalar(ref scalar) = self.abi {
|
||||||
// Use a different cache for scalars because pointers to DSTs
|
// Use a different cache for scalars because pointers to DSTs
|
||||||
// can be either fat or thin (data pointers of fat pointers).
|
// can be either fat or thin (data pointers of fat pointers).
|
||||||
|
@ -190,12 +194,9 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
||||||
}
|
}
|
||||||
let ty =
|
let ty =
|
||||||
match *self.ty.kind() {
|
match *self.ty.kind() {
|
||||||
ty::Ref(_, ty, _) | ty::RawPtr(ty::TypeAndMut { ty, .. }) => {
|
// NOTE: we cannot remove this match like in the LLVM codegen because the call
|
||||||
cx.type_ptr_to(cx.layout_of(ty).gcc_type(cx))
|
// to fn_ptr_backend_type handle the on-stack attribute.
|
||||||
}
|
// TODO(antoyo): find a less hackish way to hande the on-stack attribute.
|
||||||
ty::Adt(def, _) if def.is_box() => {
|
|
||||||
cx.type_ptr_to(cx.layout_of(self.ty.boxed_ty()).gcc_type(cx))
|
|
||||||
}
|
|
||||||
ty::FnPtr(sig) => cx.fn_ptr_backend_type(&cx.fn_abi_of_fn_ptr(sig, ty::List::empty())),
|
ty::FnPtr(sig) => cx.fn_ptr_backend_type(&cx.fn_abi_of_fn_ptr(sig, ty::List::empty())),
|
||||||
_ => self.scalar_gcc_type_at(cx, scalar, Size::ZERO),
|
_ => self.scalar_gcc_type_at(cx, scalar, Size::ZERO),
|
||||||
};
|
};
|
||||||
|
@ -272,23 +273,10 @@ impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scalar_pair_element_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, index: usize, immediate: bool) -> Type<'gcc> {
|
fn scalar_pair_element_gcc_type<'gcc>(&self, cx: &CodegenCx<'gcc, 'tcx>, index: usize) -> Type<'gcc> {
|
||||||
// TODO(antoyo): remove llvm hack:
|
// This must produce the same result for `repr(transparent)` wrappers as for the inner type!
|
||||||
// HACK(eddyb) special-case fat pointers until LLVM removes
|
// In other words, this should generally not look at the type at all, but only at the
|
||||||
// pointee types, to avoid bitcasting every `OperandRef::deref`.
|
// layout.
|
||||||
match self.ty.kind() {
|
|
||||||
ty::Ref(..) | ty::RawPtr(_) => {
|
|
||||||
return self.field(cx, index).gcc_type(cx);
|
|
||||||
}
|
|
||||||
// only wide pointer boxes are handled as pointers
|
|
||||||
// thin pointer boxes with scalar allocators are handled by the general logic below
|
|
||||||
ty::Adt(def, args) if def.is_box() && cx.layout_of(args.type_at(1)).is_zst() => {
|
|
||||||
let ptr_ty = Ty::new_mut_ptr(cx.tcx,self.ty.boxed_ty());
|
|
||||||
return cx.layout_of(ptr_ty).scalar_pair_element_gcc_type(cx, index, immediate);
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
let (a, b) = match self.abi {
|
let (a, b) = match self.abi {
|
||||||
Abi::ScalarPair(ref a, ref b) => (a, b),
|
Abi::ScalarPair(ref a, ref b) => (a, b),
|
||||||
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
_ => bug!("TyAndLayout::scalar_pair_element_llty({:?}): not applicable", self),
|
||||||
|
@ -367,8 +355,8 @@ impl<'gcc, 'tcx> LayoutTypeMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
|
||||||
layout.gcc_field_index(index)
|
layout.gcc_field_index(index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn scalar_pair_element_backend_type(&self, layout: TyAndLayout<'tcx>, index: usize, immediate: bool) -> Type<'gcc> {
|
fn scalar_pair_element_backend_type(&self, layout: TyAndLayout<'tcx>, index: usize, _immediate: bool) -> Type<'gcc> {
|
||||||
layout.scalar_pair_element_gcc_type(self, index, immediate)
|
layout.scalar_pair_element_gcc_type(self, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cast_backend_type(&self, ty: &CastTarget) -> Type<'gcc> {
|
fn cast_backend_type(&self, ty: &CastTarget) -> Type<'gcc> {
|
||||||
|
|
3
test.sh
3
test.sh
|
@ -215,7 +215,7 @@ function setup_rustc() {
|
||||||
rm config.toml || true
|
rm config.toml || true
|
||||||
|
|
||||||
cat > config.toml <<EOF
|
cat > config.toml <<EOF
|
||||||
changelog-seen = 2
|
change-id = 115898
|
||||||
|
|
||||||
[rust]
|
[rust]
|
||||||
codegen-backends = []
|
codegen-backends = []
|
||||||
|
@ -359,6 +359,7 @@ function test_rustc() {
|
||||||
git checkout tests/ui/macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs
|
git checkout tests/ui/macros/rfc-2011-nicer-assert-messages/auxiliary/common.rs
|
||||||
git checkout tests/ui/imports/ambiguous-1.rs
|
git checkout tests/ui/imports/ambiguous-1.rs
|
||||||
git checkout tests/ui/imports/ambiguous-4-extern.rs
|
git checkout tests/ui/imports/ambiguous-4-extern.rs
|
||||||
|
git checkout tests/ui/entry-point/auxiliary/bad_main_functions.rs
|
||||||
|
|
||||||
RUSTC_ARGS="$TEST_FLAGS -Csymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot"
|
RUSTC_ARGS="$TEST_FLAGS -Csymbol-mangling-version=v0 -Zcodegen-backend="$(pwd)"/../target/"$CHANNEL"/librustc_codegen_gcc."$dylib_ext" --sysroot "$(pwd)"/../build_sysroot/sysroot"
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Run-time:
|
// Run-time:
|
||||||
// status: signal
|
// status: signal
|
||||||
|
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// Run-time:
|
// Run-time:
|
||||||
// status: signal
|
// status: signal
|
||||||
|
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
// 5
|
// 5
|
||||||
// 10
|
// 10
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// 10
|
// 10
|
||||||
|
|
||||||
#![allow(internal_features, unused_attributes)]
|
#![allow(internal_features, unused_attributes)]
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics, track_caller)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// Both args: 11
|
// Both args: 11
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics,
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics,
|
||||||
unboxed_closures)]
|
unboxed_closures, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// stdout: true
|
// stdout: true
|
||||||
// 1
|
// 1
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// status: 0
|
// status: 0
|
||||||
// stdout: 1
|
// stdout: 1
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
// status: signal
|
// status: signal
|
||||||
|
|
||||||
#![allow(internal_features, unused_attributes)]
|
#![allow(internal_features, unused_attributes)]
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
// 11
|
// 11
|
||||||
|
|
||||||
#![allow(internal_features, unused_attributes)]
|
#![allow(internal_features, unused_attributes)]
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics, track_caller)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
// 10
|
// 10
|
||||||
|
|
||||||
#![allow(internal_features, unused_attributes)]
|
#![allow(internal_features, unused_attributes)]
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics, arbitrary_self_types)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, arbitrary_self_types, rustc_attrs)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_core]
|
#![no_core]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// status: 0
|
// status: 0
|
||||||
// stdout: 1
|
// stdout: 1
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// status: 0
|
// status: 0
|
||||||
// stdout: 5
|
// stdout: 5
|
||||||
|
|
||||||
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
// 12
|
// 12
|
||||||
// 1
|
// 1
|
||||||
|
|
||||||
#![feature(auto_traits, lang_items, no_core, start, intrinsics)]
|
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
|
||||||
#![allow(internal_features)]
|
#![allow(internal_features)]
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue