@@ -1174,7 +1174,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
1174
1174
pub fn read_primval ( & self , ptr : MemoryPointer , size : u64 , signed : bool ) -> EvalResult < ' tcx , PrimVal > {
1175
1175
self . check_relocation_edges ( ptr, size) ?; // Make sure we don't read part of a pointer as a pointer
1176
1176
let endianess = self . endianess ( ) ;
1177
- let bytes = self . get_bytes_unchecked ( ptr, size, self . int_align ( size) ? ) ?;
1177
+ let bytes = self . get_bytes_unchecked ( ptr, size, self . int_align ( size) ) ?;
1178
1178
// Undef check happens *after* we established that the alignment is correct.
1179
1179
// We must not return Ok() for unaligned pointers!
1180
1180
if self . check_defined ( ptr, size) . is_err ( ) {
@@ -1207,7 +1207,6 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
1207
1207
}
1208
1208
1209
1209
pub fn write_primval ( & mut self , ptr : MemoryPointer , val : PrimVal , size : u64 , signed : bool ) -> EvalResult < ' tcx > {
1210
- let align = self . int_align ( size) ?;
1211
1210
let endianess = self . endianess ( ) ;
1212
1211
1213
1212
let bytes = match val {
@@ -1237,6 +1236,7 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
1237
1236
} ;
1238
1237
1239
1238
{
1239
+ let align = self . int_align ( size) ;
1240
1240
let dst = self . get_bytes_mut ( ptr, size, align) ?;
1241
1241
if signed {
1242
1242
write_target_int ( endianess, dst, bytes as i128 ) . unwrap ( ) ;
@@ -1264,15 +1264,15 @@ impl<'a, 'tcx, M: Machine<'tcx>> Memory<'a, 'tcx, M> {
1264
1264
self . write_primval ( ptr, val, ptr_size, false )
1265
1265
}
1266
1266
1267
- fn int_align ( & self , size : u64 ) -> EvalResult < ' tcx , u64 > {
1267
+ fn int_align ( & self , size : u64 ) -> u64 {
1268
1268
// We assume pointer-sized integers have the same alignment as pointers.
1269
- // We also assume singed and unsigned integers of the same size have the same alignment.
1269
+ // We also assume signed and unsigned integers of the same size have the same alignment.
1270
1270
match size {
1271
- 1 => Ok ( self . layout . i8_align . abi ( ) ) ,
1272
- 2 => Ok ( self . layout . i16_align . abi ( ) ) ,
1273
- 4 => Ok ( self . layout . i32_align . abi ( ) ) ,
1274
- 8 => Ok ( self . layout . i64_align . abi ( ) ) ,
1275
- 16 => Ok ( self . layout . i128_align . abi ( ) ) ,
1271
+ 1 => self . layout . i8_align . abi ( ) ,
1272
+ 2 => self . layout . i16_align . abi ( ) ,
1273
+ 4 => self . layout . i32_align . abi ( ) ,
1274
+ 8 => self . layout . i64_align . abi ( ) ,
1275
+ 16 => self . layout . i128_align . abi ( ) ,
1276
1276
_ => bug ! ( "bad integer size: {}" , size) ,
1277
1277
}
1278
1278
}
0 commit comments