@@ -3,7 +3,7 @@ use std::borrow::Cow;
3
3
use rustc:: mir:: interpret:: {
4
4
read_target_uint, AllocId , GlobalAlloc , Allocation , ConstValue , InterpResult , GlobalId , Scalar ,
5
5
} ;
6
- use rustc:: ty:: Const ;
6
+ use rustc:: ty:: { Const , layout :: Align } ;
7
7
use rustc_mir:: interpret:: {
8
8
InterpCx , ImmTy , Machine , Memory , MemoryKind , OpTy , PlaceTy ,
9
9
StackPopCleanup ,
@@ -170,13 +170,13 @@ fn trans_const_place<'a, 'tcx: 'a>(
170
170
//println!("const value: {:?} allocation: {:?}", value, alloc);
171
171
let alloc_id = fx. tcx . alloc_map . lock ( ) . create_memory_alloc ( alloc) ;
172
172
fx. constants . todo . insert ( TodoItem :: Alloc ( alloc_id) ) ;
173
- let data_id = data_id_for_alloc_id ( fx. module , alloc_id) ;
173
+ let data_id = data_id_for_alloc_id ( fx. module , alloc_id, alloc . align ) ;
174
174
cplace_for_dataid ( fx, const_. ty , data_id)
175
175
}
176
176
177
- fn data_id_for_alloc_id ( module : & mut Module < impl Backend > , alloc_id : AllocId ) -> DataId {
177
+ fn data_id_for_alloc_id < B : Backend > ( module : & mut Module < B > , alloc_id : AllocId , align : Align ) -> DataId {
178
178
module
179
- . declare_data ( & format ! ( "__alloc_{}" , alloc_id. 0 ) , Linkage :: Local , false , None )
179
+ . declare_data ( & format ! ( "__alloc_{}" , alloc_id. 0 ) , Linkage :: Local , false , Some ( align . bytes ( ) as u8 ) )
180
180
. unwrap ( )
181
181
}
182
182
@@ -245,8 +245,8 @@ fn define_all_allocs(
245
245
let ( data_id, alloc) = match todo_item {
246
246
TodoItem :: Alloc ( alloc_id) => {
247
247
//println!("alloc_id {}", alloc_id);
248
- let data_id = data_id_for_alloc_id ( module, alloc_id) ;
249
248
let alloc = memory. get ( alloc_id) . unwrap ( ) ;
249
+ let data_id = data_id_for_alloc_id ( module, alloc_id, alloc. align ) ;
250
250
( data_id, alloc)
251
251
}
252
252
TodoItem :: Static ( def_id) => {
@@ -302,7 +302,7 @@ fn define_all_allocs(
302
302
}
303
303
GlobalAlloc :: Memory ( _) => {
304
304
cx. todo . insert ( TodoItem :: Alloc ( reloc) ) ;
305
- data_id_for_alloc_id ( module, reloc)
305
+ data_id_for_alloc_id ( module, reloc, alloc . align )
306
306
}
307
307
GlobalAlloc :: Static ( def_id) => {
308
308
cx. todo . insert ( TodoItem :: Static ( def_id) ) ;
0 commit comments