Skip to content

Commit bedaeda

Browse files
erikdesjardinsantoyo
authored andcommitted
create and use GlobalAlloc::address_space
1 parent 7bf0670 commit bedaeda

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;
@@ -307,12 +307,7 @@ pub fn const_alloc_to_gcc<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, alloc: ConstAl
307307
.expect("const_alloc_to_llvm: could not read relocation pointer")
308308
as u64;
309309

310-
let address_space = match cx.tcx.global_alloc(alloc_id) {
311-
GlobalAlloc::Function(..) => cx.data_layout().instruction_address_space,
312-
GlobalAlloc::Static(..) | GlobalAlloc::Memory(..) | GlobalAlloc::VTable(..) => {
313-
AddressSpace::DATA
314-
}
315-
};
310+
let address_space = cx.tcx.global_alloc(alloc_id).address_space(cx);
316311

317312
llvals.push(cx.scalar_to_backend(
318313
InterpScalar::from_pointer(

0 commit comments

Comments
 (0)