diff options
| author | Ralf Jung <post@ralfj.de> | 2023-09-12 08:42:36 +0200 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2023-09-14 07:27:31 +0200 |
| commit | 430c386821ad0df43360cf41a4bb35ac0f1d2d77 (patch) | |
| tree | 48a2052932d12f3cc490e2f1034afe6ca7a318d7 /compiler/rustc_codegen_ssa/src | |
| parent | 0f8908da27329eea3a1728492b6e842a1947211b (diff) | |
| download | rust-430c386821ad0df43360cf41a4bb35ac0f1d2d77.tar.gz rust-430c386821ad0df43360cf41a4bb35ac0f1d2d77.zip | |
make it more clear which functions create fresh AllocId
Diffstat (limited to 'compiler/rustc_codegen_ssa/src')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/mir/operand.rs | 8 |
1 files changed, 6 insertions, 2 deletions
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); |
