summaryrefslogtreecommitdiffstats
path: root/compiler/rustc_codegen_cranelift/src/constant.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /compiler/rustc_codegen_cranelift/src/constant.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src/constant.rs')
-rw-r--r--compiler/rustc_codegen_cranelift/src/constant.rs30
1 files changed, 15 insertions, 15 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs
index 77af561a5..427340c33 100644
--- a/compiler/rustc_codegen_cranelift/src/constant.rs
+++ b/compiler/rustc_codegen_cranelift/src/constant.rs
@@ -324,12 +324,12 @@ fn data_id_for_static(
let ref_name = format!("_rust_extern_with_linkage_{}", symbol_name);
let ref_data_id = module.declare_data(&ref_name, Linkage::Local, false, false).unwrap();
- let mut data_ctx = DataContext::new();
- data_ctx.set_align(align);
- let data = module.declare_data_in_data(data_id, &mut data_ctx);
- data_ctx.define(std::iter::repeat(0).take(pointer_ty(tcx).bytes() as usize).collect());
- data_ctx.write_data_addr(0, data, 0);
- match module.define_data(ref_data_id, &data_ctx) {
+ let mut data = DataDescription::new();
+ data.set_align(align);
+ let data_gv = module.declare_data_in_data(data_id, &mut data);
+ data.define(std::iter::repeat(0).take(pointer_ty(tcx).bytes() as usize).collect());
+ data.write_data_addr(0, data_gv, 0);
+ match module.define_data(ref_data_id, &data) {
// Every time the static is referenced there will be another definition of this global,
// so duplicate definitions are expected and allowed.
Err(ModuleError::DuplicateDefinition(_)) => {}
@@ -394,9 +394,9 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
continue;
}
- let mut data_ctx = DataContext::new();
+ let mut data = DataDescription::new();
let alloc = alloc.inner();
- data_ctx.set_align(alloc.align.bytes());
+ data.set_align(alloc.align.bytes());
if let Some(section_name) = section_name {
let (segment_name, section_name) = if tcx.sess.target.is_like_osx {
@@ -412,11 +412,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
} else {
("", section_name.as_str())
};
- data_ctx.set_segment_section(segment_name, section_name);
+ data.set_segment_section(segment_name, section_name);
}
let bytes = alloc.inspect_with_uninit_and_ptr_outside_interpreter(0..alloc.len()).to_vec();
- data_ctx.define(bytes.into_boxed_slice());
+ data.define(bytes.into_boxed_slice());
for &(offset, alloc_id) in alloc.provenance().ptrs().iter() {
let addend = {
@@ -435,8 +435,8 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
assert_eq!(addend, 0);
let func_id =
crate::abi::import_function(tcx, module, instance.polymorphize(tcx));
- let local_func_id = module.declare_func_in_data(func_id, &mut data_ctx);
- data_ctx.write_function_addr(offset.bytes() as u32, local_func_id);
+ let local_func_id = module.declare_func_in_data(func_id, &mut data);
+ data.write_function_addr(offset.bytes() as u32, local_func_id);
continue;
}
GlobalAlloc::Memory(target_alloc) => {
@@ -462,11 +462,11 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
}
};
- let global_value = module.declare_data_in_data(data_id, &mut data_ctx);
- data_ctx.write_data_addr(offset.bytes() as u32, global_value, addend as i64);
+ let global_value = module.declare_data_in_data(data_id, &mut data);
+ data.write_data_addr(offset.bytes() as u32, global_value, addend as i64);
}
- module.define_data(data_id, &data_ctx).unwrap();
+ module.define_data(data_id, &data).unwrap();
cx.done.insert(data_id);
}