@@ -4,8 +4,8 @@ use std::borrow::Borrow;
44
55use libc:: { c_char, c_uint} ;
66use rustc_abi as abi;
7+ use rustc_abi:: HasDataLayout ;
78use rustc_abi:: Primitive :: Pointer ;
8- use rustc_abi:: { AddressSpace , HasDataLayout } ;
99use rustc_ast:: Mutability ;
1010use rustc_codegen_ssa:: common:: TypeKind ;
1111use rustc_codegen_ssa:: traits:: * ;
@@ -269,7 +269,8 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
269269 }
270270 Scalar :: Ptr ( ptr, _size) => {
271271 let ( prov, offset) = ptr. into_parts ( ) ;
272- let ( base_addr, base_addr_space) = match self . tcx . global_alloc ( prov. alloc_id ( ) ) {
272+ let global_alloc = self . tcx . global_alloc ( prov. alloc_id ( ) ) ;
273+ let base_addr = match global_alloc {
273274 GlobalAlloc :: Memory ( alloc) => {
274275 // For ZSTs directly codegen an aligned pointer.
275276 // This avoids generating a zero-sized constant value and actually needing a
@@ -301,12 +302,10 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
301302 format ! ( "alloc_{hash:032x}" ) . as_bytes ( ) ,
302303 ) ;
303304 }
304- ( value, AddressSpace :: DATA )
305+ value
305306 }
306307 }
307- GlobalAlloc :: Function { instance, .. } => {
308- ( self . get_fn_addr ( instance) , self . data_layout ( ) . instruction_address_space )
309- }
308+ GlobalAlloc :: Function { instance, .. } => self . get_fn_addr ( instance) ,
310309 GlobalAlloc :: VTable ( ty, dyn_ty) => {
311310 let alloc = self
312311 . tcx
@@ -319,14 +318,15 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
319318 . unwrap_memory ( ) ;
320319 let init = const_alloc_to_llvm ( self , alloc, /*static*/ false ) ;
321320 let value = self . static_addr_of_impl ( init, alloc. inner ( ) . align , None ) ;
322- ( value, AddressSpace :: DATA )
321+ value
323322 }
324323 GlobalAlloc :: Static ( def_id) => {
325324 assert ! ( self . tcx. is_static( def_id) ) ;
326325 assert ! ( !self . tcx. is_thread_local_static( def_id) ) ;
327- ( self . get_static ( def_id) , AddressSpace :: DATA )
326+ self . get_static ( def_id)
328327 }
329328 } ;
329+ let base_addr_space = global_alloc. address_space ( self ) ;
330330 let llval = unsafe {
331331 llvm:: LLVMConstInBoundsGEP2 (
332332 self . type_i8 ( ) ,
0 commit comments