Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 1c978ee

Browse files
committed
Sync from rust f5559e3
2 parents 805c4a2 + 106db3e commit 1c978ee

File tree

8 files changed

+12
-35
lines changed

8 files changed

+12
-35
lines changed

example/alloc_example.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(start, core_intrinsics, alloc_error_handler)]
1+
#![feature(start, core_intrinsics)]
22
#![no_std]
33

44
extern crate alloc;
@@ -22,11 +22,6 @@ fn panic_handler(_: &core::panic::PanicInfo<'_>) -> ! {
2222
core::intrinsics::abort();
2323
}
2424

25-
#[alloc_error_handler]
26-
fn alloc_error_handler(_: alloc::alloc::Layout) -> ! {
27-
core::intrinsics::abort();
28-
}
29-
3025
#[start]
3126
fn main(_argc: isize, _argv: *const *const u8) -> isize {
3227
let world: Box<&str> = Box::new("Hello World!\0");

src/abi/returning.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use smallvec::{smallvec, SmallVec};
99
/// this adds an extra parameter pointing to where the return value needs to be stored.
1010
pub(super) fn codegen_return_param<'tcx>(
1111
fx: &mut FunctionCx<'_, '_, 'tcx>,
12-
ssa_analyzed: &rustc_index::vec::IndexVec<Local, crate::analyze::SsaKind>,
12+
ssa_analyzed: &rustc_index::IndexSlice<Local, crate::analyze::SsaKind>,
1313
block_params_iter: &mut impl Iterator<Item = Value>,
1414
) -> CPlace<'tcx> {
1515
let (ret_place, ret_param): (_, SmallVec<[_; 2]>) = match fx.fn_abi.as_ref().unwrap().ret.mode {

src/allocator.rs

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::prelude::*;
66
use rustc_ast::expand::allocator::{AllocatorKind, AllocatorTy, ALLOCATOR_METHODS};
77
use rustc_codegen_ssa::base::allocator_kind_for_codegen;
88
use rustc_session::config::OomStrategy;
9-
use rustc_span::symbol::sym;
109

1110
/// Returns whether an allocator shim was created
1211
pub(crate) fn codegen(
@@ -15,21 +14,14 @@ pub(crate) fn codegen(
1514
unwind_context: &mut UnwindContext,
1615
) -> bool {
1716
let Some(kind) = allocator_kind_for_codegen(tcx) else { return false };
18-
codegen_inner(
19-
module,
20-
unwind_context,
21-
kind,
22-
tcx.alloc_error_handler_kind(()).unwrap(),
23-
tcx.sess.opts.unstable_opts.oom,
24-
);
17+
codegen_inner(module, unwind_context, kind, tcx.sess.opts.unstable_opts.oom);
2518
true
2619
}
2720

2821
fn codegen_inner(
2922
module: &mut impl Module,
3023
unwind_context: &mut UnwindContext,
3124
kind: AllocatorKind,
32-
alloc_error_handler_kind: AllocatorKind,
3325
oom_strategy: OomStrategy,
3426
) {
3527
let usize_ty = module.target_config().pointer_type();
@@ -71,19 +63,6 @@ fn codegen_inner(
7163
);
7264
}
7365

74-
let sig = Signature {
75-
call_conv: module.target_config().default_call_conv,
76-
params: vec![AbiParam::new(usize_ty), AbiParam::new(usize_ty)],
77-
returns: vec![],
78-
};
79-
crate::common::create_wrapper_function(
80-
module,
81-
unwind_context,
82-
sig,
83-
"__rust_alloc_error_handler",
84-
&alloc_error_handler_kind.fn_name(sym::oom),
85-
);
86-
8766
let data_id = module.declare_data(OomStrategy::SYMBOL, Linkage::Export, false, false).unwrap();
8867
let mut data_ctx = DataContext::new();
8968
data_ctx.set_align(1);

src/analyze.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
use crate::prelude::*;
44

5-
use rustc_index::vec::IndexVec;
5+
use rustc_index::IndexVec;
66
use rustc_middle::mir::StatementKind::*;
77
use rustc_middle::ty::Ty;
88

src/base.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Codegen of a single function
22
33
use rustc_ast::InlineAsmOptions;
4-
use rustc_index::vec::IndexVec;
4+
use rustc_index::IndexVec;
55
use rustc_middle::ty::adjustment::PointerCast;
66
use rustc_middle::ty::layout::FnAbiOf;
77
use rustc_middle::ty::print::with_no_trimmed_paths;
@@ -772,12 +772,15 @@ fn codegen_stmt<'tcx>(
772772
let operand = operand.load_scalar(fx);
773773
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
774774
}
775-
Rvalue::NullaryOp(null_op, ty) => {
775+
Rvalue::NullaryOp(ref null_op, ty) => {
776776
assert!(lval.layout().ty.is_sized(fx.tcx, ParamEnv::reveal_all()));
777777
let layout = fx.layout_of(fx.monomorphize(ty));
778778
let val = match null_op {
779779
NullOp::SizeOf => layout.size.bytes(),
780780
NullOp::AlignOf => layout.align.abi.bytes(),
781+
NullOp::OffsetOf(fields) => {
782+
layout.offset_of_subfield(fx, fields.iter().map(|f| f.index())).bytes()
783+
}
781784
};
782785
let val = CValue::by_val(
783786
fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(val).unwrap()),

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use cranelift_codegen::isa::TargetFrontendConfig;
22
use gimli::write::FileId;
33

44
use rustc_data_structures::sync::Lrc;
5-
use rustc_index::vec::IndexVec;
5+
use rustc_index::IndexVec;
66
use rustc_middle::ty::layout::{
77
FnAbiError, FnAbiOfHelpers, FnAbiRequest, LayoutError, LayoutOfHelpers,
88
};

src/constant.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub(crate) fn eval_mir_constant<'tcx>(
9191
),
9292
},
9393
ConstantKind::Unevaluated(mir::UnevaluatedConst { def, .. }, _)
94-
if fx.tcx.is_static(def.did) =>
94+
if fx.tcx.is_static(def) =>
9595
{
9696
span_bug!(constant.span, "MIR constant refers to static");
9797
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ mod prelude {
9090

9191
pub(crate) use rustc_data_structures::fx::FxHashMap;
9292

93-
pub(crate) use rustc_index::vec::Idx;
93+
pub(crate) use rustc_index::Idx;
9494

9595
pub(crate) use cranelift_codegen::ir::condcodes::{FloatCC, IntCC};
9696
pub(crate) use cranelift_codegen::ir::function::Function;

0 commit comments

Comments
 (0)