Fix ptr_offset_from intrinsic

This commit is contained in:
bjorn3 2020-05-01 12:32:23 +02:00
parent de336e17e4
commit aa6a4acd78

View File

@ -812,7 +812,7 @@ fn swap(bcx: &mut FunctionBuilder<'_>, v: Value) -> Value {
let pointee_size: u64 = fx.layout_of(T).size.bytes();
let diff = fx.bcx.ins().isub(ptr, base);
// FIXME this can be an exact division.
let val = CValue::by_val(fx.bcx.ins().udiv_imm(diff, pointee_size as i64), isize_layout);
let val = CValue::by_val(fx.bcx.ins().sdiv_imm(diff, pointee_size as i64), isize_layout);
ret.write_cvalue(fx, val);
};