Skip to content

Commit d1ea699

Browse files
committed
use AllocId instead of Allocation in ConstValue::ByRef
1 parent 1956fb8 commit d1ea699

File tree

2 files changed

+11
-6
lines changed

2 files changed

+11
-6
lines changed

src/constant.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ pub(crate) fn codegen_const_value<'tcx>(
200200
CValue::by_val(val, layout)
201201
}
202202
},
203-
ConstValue::ByRef { alloc, offset } => CValue::by_ref(
204-
pointer_for_allocation(fx, alloc)
205-
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
206-
layout,
207-
),
203+
ConstValue::ByRef { alloc_id, offset } => {
204+
let alloc = fx.tcx.global_alloc(alloc_id).unwrap_memory();
205+
// FIXME: avoid creating multiple allocations for the same AllocId?
206+
CValue::by_ref(
207+
pointer_for_allocation(fx, alloc)
208+
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
209+
layout,
210+
)
211+
}
208212
ConstValue::Slice { data, start, end } => {
209213
let ptr = pointer_for_allocation(fx, data)
210214
.offset_i64(fx, i64::try_from(start).unwrap())

src/intrinsics/simd.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,8 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
172172
.expect("simd_shuffle idx not const");
173173

174174
let idx_bytes = match idx_const {
175-
ConstValue::ByRef { alloc, offset } => {
175+
ConstValue::ByRef { alloc_id, offset } => {
176+
let alloc = fx.tcx.global_alloc(alloc_id).unwrap_memory();
176177
let size = Size::from_bytes(
177178
4 * ret_lane_count, /* size_of([u32; ret_lane_count]) */
178179
);

0 commit comments

Comments
 (0)