diff options
| author | Erik Desjardins <erikdesjardins@users.noreply.github.com> | 2023-01-25 01:46:19 -0500 |
|---|---|---|
| committer | Antoni Boucher <bouanto@zoho.com> | 2023-02-28 22:03:22 -0500 |
| commit | bedaeda5084ab94fde088de0dba80e3bdc2363ef (patch) | |
| tree | dc4c1da3678c1156c35a0dcdb3743406a570b672 /src | |
| parent | 7bf06701693934ded0774f0c17f45943cdbe44f3 (diff) | |
| download | rust-bedaeda5084ab94fde088de0dba80e3bdc2363ef.tar.gz rust-bedaeda5084ab94fde088de0dba80e3bdc2363ef.zip | |
create and use GlobalAlloc::address_space
Diffstat (limited to 'src')
| -rw-r--r-- | src/consts.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/src/consts.rs b/src/consts.rs index 52e5ea77787..b651b60924f 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -7,9 +7,9 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs} use rustc_middle::mir::mono::MonoItem; use rustc_middle::ty::{self, Instance, Ty}; use rustc_middle::ty::layout::LayoutOf; -use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, GlobalAlloc, Scalar as InterpScalar, read_target_uint}; +use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint}; use rustc_span::def_id::DefId; -use rustc_target::abi::{self, AddressSpace, Align, HasDataLayout, Primitive, Size, WrappingRange}; +use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange}; use crate::base; use crate::context::CodegenCx; @@ -307,12 +307,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl .expect("const_alloc_to_llvm: could not read relocation pointer") as u64; - let address_space = match cx.tcx.global_alloc(alloc_id) { - GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space, - GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => { - AddressSpace::DATA - } - }; + let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx); llvals.push(cx.scalar_to_backend( InterpScalar::from_pointer( |
