Skip to content

Commit df44afe

Browse files
authored
Merge pull request #19269 from lnicola/sync-from-rust
minor: sync from downstream
2 parents e8f3ac5 + a66a0ed commit df44afe

13 files changed

Lines changed: 43 additions & 114 deletions

File tree

example/mini_core.rs

Lines changed: 13 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -591,70 +591,31 @@ pub union MaybeUninit<T> {
591591

592592
pub mod intrinsics {
593593
#[rustc_intrinsic]
594-
#[rustc_intrinsic_must_be_overridden]
595-
pub fn abort() -> ! {
596-
loop {}
597-
}
594+
pub fn abort() -> !;
598595
#[rustc_intrinsic]
599-
#[rustc_intrinsic_must_be_overridden]
600-
pub fn size_of<T>() -> usize {
601-
loop {}
602-
}
596+
pub fn size_of<T>() -> usize;
603597
#[rustc_intrinsic]
604-
#[rustc_intrinsic_must_be_overridden]
605-
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize {
606-
loop {}
607-
}
598+
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize;
608599
#[rustc_intrinsic]
609-
#[rustc_intrinsic_must_be_overridden]
610-
pub fn min_align_of<T>() -> usize {
611-
loop {}
612-
}
600+
pub fn min_align_of<T>() -> usize;
613601
#[rustc_intrinsic]
614-
#[rustc_intrinsic_must_be_overridden]
615-
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize {
616-
loop {}
617-
}
602+
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize;
618603
#[rustc_intrinsic]
619-
#[rustc_intrinsic_must_be_overridden]
620-
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) {
621-
loop {}
622-
}
604+
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize);
623605
#[rustc_intrinsic]
624-
#[rustc_intrinsic_must_be_overridden]
625-
pub unsafe fn transmute<T, U>(_e: T) -> U {
626-
loop {}
627-
}
606+
pub unsafe fn transmute<T, U>(_e: T) -> U;
628607
#[rustc_intrinsic]
629-
#[rustc_intrinsic_must_be_overridden]
630-
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 {
631-
loop {}
632-
}
608+
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32;
633609
#[rustc_intrinsic]
634-
#[rustc_intrinsic_must_be_overridden]
635-
pub fn needs_drop<T: ?::Sized>() -> bool {
636-
loop {}
637-
}
610+
pub fn needs_drop<T: ?::Sized>() -> bool;
638611
#[rustc_intrinsic]
639-
#[rustc_intrinsic_must_be_overridden]
640-
pub fn bitreverse<T>(_x: T) -> T {
641-
loop {}
642-
}
612+
pub fn bitreverse<T>(_x: T) -> T;
643613
#[rustc_intrinsic]
644-
#[rustc_intrinsic_must_be_overridden]
645-
pub fn bswap<T>(_x: T) -> T {
646-
loop {}
647-
}
614+
pub fn bswap<T>(_x: T) -> T;
648615
#[rustc_intrinsic]
649-
#[rustc_intrinsic_must_be_overridden]
650-
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) {
651-
loop {}
652-
}
616+
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize);
653617
#[rustc_intrinsic]
654-
#[rustc_intrinsic_must_be_overridden]
655-
pub unsafe fn unreachable() -> ! {
656-
loop {}
657-
}
618+
pub unsafe fn unreachable() -> !;
658619
}
659620

660621
pub mod libc {

src/back/lto.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -632,17 +632,16 @@ pub unsafe fn optimize_thin_module(
632632
Arc::new(SyncContext::new(context))
633633
}
634634
};
635-
let module = ModuleCodegen {
636-
module_llvm: GccContext {
635+
let module = ModuleCodegen::new_regular(
636+
thin_module.name().to_string(),
637+
GccContext {
637638
context,
638639
should_combine_object_files,
639640
// TODO(antoyo): use the correct relocation model here.
640641
relocation_model: RelocModel::Pic,
641642
temp_dir: None,
642643
},
643-
name: thin_module.name().to_string(),
644-
kind: ModuleKind::Regular,
645-
};
644+
);
646645
/*{
647646
let target = &*module.module_llvm.tm;
648647
let llmod = module.module_llvm.llmod();

src/base.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use std::sync::Arc;
44
use std::time::Instant;
55

66
use gccjit::{CType, Context, FunctionType, GlobalKind};
7+
use rustc_codegen_ssa::ModuleCodegen;
78
use rustc_codegen_ssa::base::maybe_create_entry_wrapper;
89
use rustc_codegen_ssa::mono_item::MonoItemExt;
910
use rustc_codegen_ssa::traits::DebugInfoCodegenMethods;
10-
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind};
1111
use rustc_middle::dep_graph;
1212
use rustc_middle::mir::mono::Linkage;
1313
#[cfg(feature = "master")]
@@ -237,16 +237,15 @@ pub fn compile_codegen_unit(
237237
}
238238
}
239239

240-
ModuleCodegen {
241-
name: cgu_name.to_string(),
242-
module_llvm: GccContext {
240+
ModuleCodegen::new_regular(
241+
cgu_name.to_string(),
242+
GccContext {
243243
context: Arc::new(SyncContext::new(context)),
244244
relocation_model: tcx.sess.relocation_model(),
245245
should_combine_object_files: false,
246246
temp_dir: None,
247247
},
248-
kind: ModuleKind::Regular,
249-
}
248+
)
250249
}
251250

252251
(module, cost)

src/intrinsic/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ impl<'a, 'gcc, 'tcx> IntrinsicCallBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tc
312312
let layout = self.layout_of(tp_ty).layout;
313313
let _use_integer_compare = match layout.backend_repr() {
314314
Scalar(_) | ScalarPair(_, _) => true,
315-
Vector { .. } => false,
315+
SimdVector { .. } => false,
316316
Memory { .. } => {
317317
// For rusty ABIs, small aggregates are actually passed
318318
// as `RegKind::Integer` (see `FnAbi::adjust_for_abi`),

src/intrinsic/simd.rs

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -772,8 +772,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
772772
sym::simd_floor => "floor",
773773
sym::simd_fma => "fma",
774774
sym::simd_relaxed_fma => "fma", // FIXME: this should relax to non-fused multiply-add when necessary
775-
sym::simd_fpowi => "__builtin_powi",
776-
sym::simd_fpow => "pow",
777775
sym::simd_fsin => "sin",
778776
sym::simd_fsqrt => "sqrt",
779777
sym::simd_round => "round",
@@ -788,24 +786,16 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
788786
let mut vector_elements = vec![];
789787
for i in 0..in_len {
790788
let index = bx.context.new_rvalue_from_long(bx.ulong_type, i as i64);
791-
// we have to treat fpowi specially, since fpowi's second argument is always an i32
792789
let mut arguments = vec![];
793-
if name == sym::simd_fpowi {
794-
arguments = vec![
795-
bx.extract_element(args[0].immediate(), index).to_rvalue(),
796-
args[1].immediate(),
797-
];
798-
} else {
799-
for arg in args {
800-
let mut element = bx.extract_element(arg.immediate(), index).to_rvalue();
801-
// FIXME: it would probably be better to not have casts here and use the proper
802-
// instructions.
803-
if let Some(typ) = cast_type {
804-
element = bx.context.new_cast(None, element, typ);
805-
}
806-
arguments.push(element);
790+
for arg in args {
791+
let mut element = bx.extract_element(arg.immediate(), index).to_rvalue();
792+
// FIXME: it would probably be better to not have casts here and use the proper
793+
// instructions.
794+
if let Some(typ) = cast_type {
795+
element = bx.context.new_cast(None, element, typ);
807796
}
808-
};
797+
arguments.push(element);
798+
}
809799
let mut result = bx.context.new_call(None, function, &arguments);
810800
if cast_type.is_some() {
811801
result = bx.context.new_cast(None, result, elem_ty);
@@ -829,8 +819,6 @@ pub fn generic_simd_intrinsic<'a, 'gcc, 'tcx>(
829819
| sym::simd_floor
830820
| sym::simd_fma
831821
| sym::simd_relaxed_fma
832-
| sym::simd_fpow
833-
| sym::simd_fpowi
834822
| sym::simd_fsin
835823
| sym::simd_fsqrt
836824
| sym::simd_round

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ impl WriteBackendMethods for GccCodegenBackend {
393393
unsafe fn optimize(
394394
_cgcx: &CodegenContext<Self>,
395395
_dcx: DiagCtxtHandle<'_>,
396-
module: &ModuleCodegen<Self::Module>,
396+
module: &mut ModuleCodegen<Self::Module>,
397397
config: &ModuleConfig,
398398
) -> Result<(), FatalError> {
399399
module.module_llvm.context.set_optimization_level(to_gcc_opt_level(config.opt_level));

src/type_of.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ fn uncached_gcc_type<'gcc, 'tcx>(
6363
) -> Type<'gcc> {
6464
match layout.backend_repr {
6565
BackendRepr::Scalar(_) => bug!("handled elsewhere"),
66-
BackendRepr::Vector { ref element, count } => {
66+
BackendRepr::SimdVector { ref element, count } => {
6767
let element = layout.scalar_gcc_type_at(cx, element, Size::ZERO);
6868
let element =
6969
// NOTE: gcc doesn't allow pointer types in vectors.
@@ -178,17 +178,17 @@ pub trait LayoutGccExt<'tcx> {
178178
impl<'tcx> LayoutGccExt<'tcx> for TyAndLayout<'tcx> {
179179
fn is_gcc_immediate(&self) -> bool {
180180
match self.backend_repr {
181-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } => true,
181+
BackendRepr::Scalar(_) | BackendRepr::SimdVector { .. } => true,
182182
BackendRepr::ScalarPair(..) | BackendRepr::Memory { .. } => false,
183183
}
184184
}
185185

186186
fn is_gcc_scalar_pair(&self) -> bool {
187187
match self.backend_repr {
188188
BackendRepr::ScalarPair(..) => true,
189-
BackendRepr::Scalar(_) | BackendRepr::Vector { .. } | BackendRepr::Memory { .. } => {
190-
false
191-
}
189+
BackendRepr::Scalar(_)
190+
| BackendRepr::SimdVector { .. }
191+
| BackendRepr::Memory { .. } => false,
192192
}
193193
}
194194

tests/run/abort1.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ mod intrinsics {
3636

3737
#[rustc_nounwind]
3838
#[rustc_intrinsic]
39-
#[rustc_intrinsic_must_be_overridden]
40-
pub fn abort() -> ! {
41-
loop {}
42-
}
39+
pub fn abort() -> !;
4340
}
4441

4542
/*

tests/run/abort2.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,7 @@ mod intrinsics {
3636

3737
#[rustc_nounwind]
3838
#[rustc_intrinsic]
39-
#[rustc_intrinsic_must_be_overridden]
40-
pub fn abort() -> ! {
41-
loop {}
42-
}
39+
pub fn abort() -> !;
4340
}
4441

4542
/*

tests/run/assign.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,7 @@ mod libc {
5959
mod intrinsics {
6060
#[rustc_nounwind]
6161
#[rustc_intrinsic]
62-
#[rustc_intrinsic_must_be_overridden]
63-
pub fn abort() -> ! {
64-
loop {}
65-
}
62+
pub fn abort() -> !;
6663
}
6764

6865
#[lang = "panic"]

0 commit comments

Comments
 (0)