Skip to content

Commit 01241f8

Browse files
create and use GlobalAlloc::address_space
1 parent 559b57e commit 01241f8

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/consts.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use rustc_middle::middle::codegen_fn_attrs::{CodegenFnAttrFlags, CodegenFnAttrs}
77
use rustc_middle::mir::mono::MonoItem;
88
use rustc_middle::ty::{self, Instance, Ty};
99
use rustc_middle::ty::layout::LayoutOf;
10-
use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, GlobalAlloc, Scalar as InterpScalar, read_target_uint};
10+
use rustc_middle::mir::interpret::{self, ConstAllocation, ErrorHandled, Scalar as InterpScalar, read_target_uint};
1111
use rustc_span::def_id::DefId;
12-
use rustc_target::abi::{self, AddressSpace, Align, HasDataLayout, Primitive, Size, WrappingRange};
12+
use rustc_target::abi::{self, Align, HasDataLayout, Primitive, Size, WrappingRange};
1313

1414
use crate::base;
1515
use crate::context::CodegenCx;
@@ -323,12 +323,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
323323
.expect("const_alloc_to_llvm: could not read relocation pointer")
324324
as u64;
325325

326-
let address_space = match cx.tcx.global_alloc(alloc_id) {
327-
GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space,
328-
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
329-
AddressSpace::DATA
330-
}
331-
};
326+
let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx);
332327

333328
llvals.push(cx.scalar_to_backend(
334329
InterpScalar::from_pointer(

0 commit comments

Comments
 (0)