@@ -4,8 +4,8 @@ use std::borrow::Borrow;
4
4
5
5
use libc:: { c_char, c_uint} ;
6
6
use rustc_abi as abi;
7
+ use rustc_abi:: HasDataLayout ;
7
8
use rustc_abi:: Primitive :: Pointer ;
8
- use rustc_abi:: { AddressSpace , HasDataLayout } ;
9
9
use rustc_ast:: Mutability ;
10
10
use rustc_codegen_ssa:: common:: TypeKind ;
11
11
use rustc_codegen_ssa:: traits:: * ;
@@ -269,7 +269,8 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
269
269
}
270
270
Scalar :: Ptr ( ptr, _size) => {
271
271
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 {
273
274
GlobalAlloc :: Memory ( alloc) => {
274
275
// For ZSTs directly codegen an aligned pointer.
275
276
// This avoids generating a zero-sized constant value and actually needing a
@@ -301,12 +302,10 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
301
302
format ! ( "alloc_{hash:032x}" ) . as_bytes ( ) ,
302
303
) ;
303
304
}
304
- ( value, AddressSpace :: DATA )
305
+ value
305
306
}
306
307
}
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) ,
310
309
GlobalAlloc :: VTable ( ty, dyn_ty) => {
311
310
let alloc = self
312
311
. tcx
@@ -319,14 +318,15 @@ impl<'ll, 'tcx> ConstCodegenMethods for CodegenCx<'ll, 'tcx> {
319
318
. unwrap_memory ( ) ;
320
319
let init = const_alloc_to_llvm ( self , alloc, /*static*/ false ) ;
321
320
let value = self . static_addr_of_impl ( init, alloc. inner ( ) . align , None ) ;
322
- ( value, AddressSpace :: DATA )
321
+ value
323
322
}
324
323
GlobalAlloc :: Static ( def_id) => {
325
324
assert ! ( self . tcx. is_static( def_id) ) ;
326
325
assert ! ( !self . tcx. is_thread_local_static( def_id) ) ;
327
- ( self . get_static ( def_id) , AddressSpace :: DATA )
326
+ self . get_static ( def_id)
328
327
}
329
328
} ;
329
+ let base_addr_space = global_alloc. address_space ( self ) ;
330
330
let llval = unsafe {
331
331
llvm:: LLVMConstInBoundsGEP2 (
332
332
self . type_i8 ( ) ,
0 commit comments