Skip to content

Commit 9e67c9b

Browse files
authored
Merge pull request #2508 from rust-lang/rustc-pull
Rustc pull update
2 parents 4859cae + 7ffa5d0 commit 9e67c9b

5 files changed

Lines changed: 45 additions & 17 deletions

File tree

src/abi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,7 @@ pub(crate) fn codegen_drop<'tcx>(
786786

787787
pub(crate) fn lib_call_arg_param(tcx: TyCtxt<'_>, ty: Type, is_signed: bool) -> AbiParam {
788788
let param = AbiParam::new(ty);
789-
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size.bits() {
789+
if ty.is_int() && u64::from(ty.bits()) < tcx.data_layout.pointer_size().bits() {
790790
match (&*tcx.sess.target.arch, &*tcx.sess.target.vendor) {
791791
("x86_64", _) | ("aarch64", "apple") => match (ty, is_signed) {
792792
(types::I8 | types::I16, true) => param.sext(),

src/abi/pass_mode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<'tcx> ArgAbiExt<'tcx> for ArgAbi<'tcx, Ty<'tcx>> {
127127
PassMode::Indirect { attrs, meta_attrs: None, on_stack } => {
128128
if on_stack {
129129
// Abi requires aligning struct size to pointer size
130-
let size = self.layout.size.align_to(tcx.data_layout.pointer_align.abi);
130+
let size = self.layout.size.align_to(tcx.data_layout.pointer_align().abi);
131131
let size = u32::try_from(size.bytes()).unwrap();
132132
smallvec![apply_attrs_to_abi_param(
133133
AbiParam::special(pointer_ty(tcx), ArgumentPurpose::StructArgument(size),),

src/allocator.rs

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -84,19 +84,34 @@ fn codegen_inner(
8484
&mangle_internal_symbol(tcx, alloc_error_handler_name(alloc_error_handler_kind)),
8585
);
8686

87-
let data_id = module
88-
.declare_data(
89-
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
90-
Linkage::Export,
91-
false,
92-
false,
93-
)
94-
.unwrap();
95-
let mut data = DataDescription::new();
96-
data.set_align(1);
97-
let val = oom_strategy.should_panic();
98-
data.define(Box::new([val]));
99-
module.define_data(data_id, &data).unwrap();
87+
{
88+
let sig = Signature {
89+
call_conv: module.target_config().default_call_conv,
90+
params: vec![],
91+
returns: vec![AbiParam::new(types::I8)],
92+
};
93+
let func_id = module
94+
.declare_function(
95+
&mangle_internal_symbol(tcx, OomStrategy::SYMBOL),
96+
Linkage::Export,
97+
&sig,
98+
)
99+
.unwrap();
100+
let mut ctx = Context::new();
101+
ctx.func.signature = sig;
102+
{
103+
let mut func_ctx = FunctionBuilderContext::new();
104+
let mut bcx = FunctionBuilder::new(&mut ctx.func, &mut func_ctx);
105+
106+
let block = bcx.create_block();
107+
bcx.switch_to_block(block);
108+
let value = bcx.ins().iconst(types::I8, oom_strategy.should_panic() as i64);
109+
bcx.ins().return_(&[value]);
110+
bcx.seal_all_blocks();
111+
bcx.finalize();
112+
}
113+
module.define_function(func_id, &mut ctx).unwrap();
114+
}
100115

101116
{
102117
let sig = Signature {

src/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::debuginfo::FunctionDebugContext;
1515
use crate::prelude::*;
1616

1717
pub(crate) fn pointer_ty(tcx: TyCtxt<'_>) -> types::Type {
18-
match tcx.data_layout.pointer_size.bits() {
18+
match tcx.data_layout.pointer_size().bits() {
1919
16 => types::I16,
2020
32 => types::I32,
2121
64 => types::I64,

src/constant.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,13 @@ pub(crate) fn codegen_const_value<'tcx>(
175175
fx.module.declare_data_in_func(data_id, &mut fx.bcx.func);
176176
fx.bcx.ins().global_value(fx.pointer_type, local_data_id)
177177
}
178+
GlobalAlloc::TypeId { .. } => {
179+
return CValue::const_val(
180+
fx,
181+
layout,
182+
ScalarInt::try_from_target_usize(offset.bytes(), fx.tcx).unwrap(),
183+
);
184+
}
178185
GlobalAlloc::Static(def_id) => {
179186
assert!(fx.tcx.is_static(def_id));
180187
let data_id = data_id_for_static(
@@ -360,6 +367,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
360367
GlobalAlloc::Memory(alloc) => alloc,
361368
GlobalAlloc::Function { .. }
362369
| GlobalAlloc::Static(_)
370+
| GlobalAlloc::TypeId { .. }
363371
| GlobalAlloc::VTable(..) => {
364372
unreachable!()
365373
}
@@ -443,7 +451,7 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
443451
let addend = {
444452
let endianness = tcx.data_layout.endian;
445453
let offset = offset.bytes() as usize;
446-
let ptr_size = tcx.data_layout.pointer_size;
454+
let ptr_size = tcx.data_layout.pointer_size();
447455
let bytes = &alloc.inspect_with_uninit_and_ptr_outside_interpreter(
448456
offset..offset + ptr_size.bytes() as usize,
449457
);
@@ -471,6 +479,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
471479
.principal()
472480
.map(|principal| tcx.instantiate_bound_regions_with_erased(principal)),
473481
),
482+
GlobalAlloc::TypeId { .. } => {
483+
// Nothing to do, the bytes/offset of this pointer have already been written together with all other bytes,
484+
// so we just need to drop this provenance.
485+
continue;
486+
}
474487
GlobalAlloc::Static(def_id) => {
475488
if tcx.codegen_fn_attrs(def_id).flags.contains(CodegenFnAttrFlags::THREAD_LOCAL)
476489
{

0 commit comments

Comments
 (0)