Auto merge of #30996 - oli-obk:fix/load_range_assert, r=nagisa
it makes no sense here, accidentally introduced in #30931 r? @dotdash
This commit is contained in:
commit
50a8333300
@ -956,7 +956,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
|
||||
assert_eq!(val_ty(ptr), llty.ptr_to());
|
||||
let bits = machine::llbitsize_of_real(bcx.ccx(), llty);
|
||||
assert!(bits <= 64);
|
||||
let bits = bits as usize;
|
||||
let bits = bits as usize;
|
||||
let mask = Disr(!0u64 >> (64 - bits));
|
||||
// For a (max) discr of -1, max will be `-1 as usize`, which overflows.
|
||||
// However, that is fine here (it would still represent the full range),
|
||||
@ -969,7 +969,7 @@ fn load_discr(bcx: Block, ity: IntType, ptr: ValueRef, min: Disr, max: Disr)
|
||||
} else {
|
||||
// llvm::ConstantRange can deal with ranges that wrap around,
|
||||
// so an overflow on (max + 1) is fine.
|
||||
LoadRangeAssert(bcx, ptr, min, max.wrapping_add(Disr(1)), /* signed: */ True)
|
||||
LoadRangeAssert(bcx, ptr, min.0, max.0.wrapping_add(1), /* signed: */ True)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1023,11 +1023,11 @@ pub fn load_ty<'blk, 'tcx>(cx: Block<'blk, 'tcx>, ptr: ValueRef, t: Ty<'tcx>) ->
|
||||
}
|
||||
|
||||
let val = if t.is_bool() {
|
||||
LoadRangeAssert(cx, ptr, Disr(0), Disr(2), llvm::False)
|
||||
LoadRangeAssert(cx, ptr, 0, 2, llvm::False)
|
||||
} else if t.is_char() {
|
||||
// a char is a Unicode codepoint, and so takes values from 0
|
||||
// to 0x10FFFF inclusive only.
|
||||
LoadRangeAssert(cx, ptr, Disr(0), Disr(0x10FFFF + 1), llvm::False)
|
||||
LoadRangeAssert(cx, ptr, 0, 0x10FFFF + 1, llvm::False)
|
||||
} else if (t.is_region_ptr() || t.is_unique()) && !common::type_is_fat_ptr(cx.tcx(), t) {
|
||||
LoadNonNull(cx, ptr)
|
||||
} else {
|
||||
|
@ -21,7 +21,6 @@ use syntax::codemap::Span;
|
||||
use trans::builder::Builder;
|
||||
use trans::type_::Type;
|
||||
use trans::debuginfo::DebugLoc;
|
||||
use trans::Disr;
|
||||
|
||||
use libc::{c_uint, c_char};
|
||||
|
||||
@ -578,8 +577,8 @@ pub fn AtomicLoad(cx: Block, pointer_val: ValueRef, order: AtomicOrdering) -> Va
|
||||
}
|
||||
|
||||
|
||||
pub fn LoadRangeAssert(cx: Block, pointer_val: ValueRef, lo: Disr,
|
||||
hi: Disr, signed: llvm::Bool) -> ValueRef {
|
||||
pub fn LoadRangeAssert(cx: Block, pointer_val: ValueRef, lo: u64,
|
||||
hi: u64, signed: llvm::Bool) -> ValueRef {
|
||||
if cx.unreachable.get() {
|
||||
let ccx = cx.fcx.ccx;
|
||||
let ty = val_ty(pointer_val);
|
||||
@ -592,7 +591,7 @@ pub fn LoadRangeAssert(cx: Block, pointer_val: ValueRef, lo: Disr,
|
||||
llvm::LLVMGetUndef(eltty.to_ref())
|
||||
}
|
||||
} else {
|
||||
B(cx).load_range_assert(pointer_val, lo.0, hi.0, signed)
|
||||
B(cx).load_range_assert(pointer_val, lo, hi, signed)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ use trans::monomorphize;
|
||||
use trans::type_::Type;
|
||||
use trans::type_of::*;
|
||||
use trans::type_of;
|
||||
use trans::Disr;
|
||||
use middle::infer;
|
||||
use middle::ty::{self, Ty};
|
||||
use middle::subst::Substs;
|
||||
@ -335,7 +334,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
|
||||
llarg_rust
|
||||
} else {
|
||||
if passed_arg_tys[i].is_bool() {
|
||||
let val = LoadRangeAssert(bcx, llarg_rust, Disr(0), Disr(2), llvm::False);
|
||||
let val = LoadRangeAssert(bcx, llarg_rust, 0, 2, llvm::False);
|
||||
Trunc(bcx, val, Type::i1(bcx.ccx()))
|
||||
} else {
|
||||
Load(bcx, llarg_rust)
|
||||
|
Loading…
Reference in New Issue
Block a user