From 430c386821ad0df43360cf41a4bb35ac0f1d2d77 Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Tue, 12 Sep 2023 08:42:36 +0200 Subject: make it more clear which functions create fresh AllocId --- compiler/rustc_codegen_ssa/src/mir/operand.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'compiler/rustc_codegen_ssa/src') diff --git a/compiler/rustc_codegen_ssa/src/mir/operand.rs b/compiler/rustc_codegen_ssa/src/mir/operand.rs index d3101df7a6a..1926bb8df52 100644 --- a/compiler/rustc_codegen_ssa/src/mir/operand.rs +++ b/compiler/rustc_codegen_ssa/src/mir/operand.rs @@ -105,7 +105,10 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { bug!("from_const: invalid ScalarPair layout: {:#?}", layout); }; let a = Scalar::from_pointer( - Pointer::new(bx.tcx().create_memory_alloc(data), Size::from_bytes(start)), + Pointer::new( + bx.tcx().reserve_and_set_memory_alloc(data), + Size::from_bytes(start), + ), &bx.tcx(), ); let a_llval = bx.scalar_to_backend( @@ -118,7 +121,6 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { } ConstValue::Indirect { alloc_id, offset } => { let alloc = bx.tcx().global_alloc(alloc_id).unwrap_memory(); - // FIXME: should we attempt to avoid building the same AllocId multiple times? return Self::from_const_alloc(bx, layout, alloc, offset); } }; @@ -184,6 +186,8 @@ impl<'a, 'tcx, V: CodegenObject> OperandRef<'tcx, V> { _ if layout.is_zst() => OperandRef::zero_sized(layout), _ => { // Neither a scalar nor scalar pair. Load from a place + // FIXME: should we cache `const_data_from_alloc` to avoid repeating this for the + // same `ConstAllocation`? let init = bx.const_data_from_alloc(alloc); let base_addr = bx.static_addr_of(init, alloc_align, None); -- cgit 1.4.1-3-g733a5