diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-11 20:01:48 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-14 07:26:24 +0200 |
| commit | 551f481ffb5b510cdb8cdf4d89d71f105b9b29ba (patch) | |
| tree | 305ce8917c7d6e02ea9ae8e24ca3d8df15e7eea4 /compiler/rustc_codegen_cranelift | |
| parent | c728bf3963433062b91bd84ffcb37d15416b800e (diff) | |
| download | rust-551f481ffb5b510cdb8cdf4d89d71f105b9b29ba.tar.gz rust-551f481ffb5b510cdb8cdf4d89d71f105b9b29ba.zip | |
use AllocId instead of Allocation in ConstValue::ByRef
Diffstat (limited to 'compiler/rustc_codegen_cranelift')
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/constant.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/compiler/rustc_codegen_cranelift/src/constant.rs b/compiler/rustc_codegen_cranelift/src/constant.rs index b9d4bc9ff29..a60964f0f75 100644 --- a/compiler/rustc_codegen_cranelift/src/constant.rs +++ b/compiler/rustc_codegen_cranelift/src/constant.rs @@ -200,11 +200,15 @@ pub(crate) fn codegen_const_value<'tcx>( CValue::by_val(val, layout) } }, - ConstValue::ByRef { alloc, offset } => CValue::by_ref( - pointer_for_allocation(fx, alloc) - .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), - layout, - ), + ConstValue::ByRef { alloc_id, offset } => { + let alloc = fx.tcx.global_alloc(alloc_id).unwrap_memory(); + // FIXME: avoid creating multiple allocations for the same AllocId? + CValue::by_ref( + pointer_for_allocation(fx, alloc) + .offset_i64(fx, i64::try_from(offset.bytes()).unwrap()), + layout, + ) + } ConstValue::Slice { data, start, end } => { let ptr = pointer_for_allocation(fx, data) .offset_i64(fx, i64::try_from(start).unwrap()) diff --git a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs index 9863e40b5b7..e17d587076f 100644 --- a/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs +++ b/compiler/rustc_codegen_cranelift/src/intrinsics/simd.rs @@ -172,7 +172,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>( .expect("simd_shuffle idx not const"); let idx_bytes = match idx_const { - ConstValue::ByRef { alloc, offset } => { + ConstValue::ByRef { alloc_id, offset } => { + let alloc = fx.tcx.global_alloc(alloc_id).unwrap_memory(); let size = Size::from_bytes( 4 * ret_lane_count, /* size_of([u32; ret_lane_count]) */ ); |
