diff options
| author | bors <bors@rust-lang.org> | 2023-09-21 08:01:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-09-21 08:01:45 +0000 |
| commit | d2db689e1efa5b3fff6b664b6d2dba0ef65b80e7 (patch) | |
| tree | e947a059c42ff87214337cc3a825e0b338af394d /compiler/rustc_codegen_cranelift/src | |
| parent | 70f3d3e6ad6656546f79fac961ed3a4316003fa3 (diff) | |
| parent | ed8fbcb05910f4439ec572bd163cc99a3603e378 (diff) | |
| download | rust-d2db689e1efa5b3fff6b664b6d2dba0ef65b80e7.tar.gz rust-d2db689e1efa5b3fff6b664b6d2dba0ef65b80e7.zip | |
Auto merge of #3069 - rust-lang:rustup-2023-09-21, r=RalfJung
Automatic sync from rustc
Diffstat (limited to 'compiler/rustc_codegen_cranelift/src')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/constant.rs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index 0d9bd3cf240..151674b2d6d 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -2,7 +2,8 @@ use rustc_data_structures::fx::{FxHashMap, FxHashSet}; use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; -use rustc_middle::mir::interpret::{read_target_uint, AllocId, ConstValue, GlobalAlloc, Scalar}; +use rustc_middle::mir::interpret::{read_target_uint, AllocId, GlobalAlloc, Scalar}; +use rustc_middle::mir::ConstValue; use cranelift_module::*; @@ -183,15 +184,11 @@ pub(crate) fn codegen_const_value<'tcx>( .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), layout, ), - ConstValue::Slice { data, start, end } => { + ConstValue::Slice { data, meta } => { let alloc_id = fx.tcx.reserve_and_set_memory_alloc(data); - let ptr = pointer_for_allocation(fx, alloc_id) - .offset_i64(fx, i64::try_from(start).unwrap()) - .get_addr(fx); - let len = fx - .bcx - .ins() - .iconst(fx.pointer_type, i64::try_from(end.checked_sub(start).unwrap()).unwrap()); + let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx); + // FIXME: the `try_from` here can actually fail, e.g. for very long ZST slices. + let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(meta).unwrap()); CValue::by_val_pair(ptr, len, layout) } } |
