Skip to content

Commit

Permalink
Auto merge of #30996 - oli-obk:fix/load_range_assert, r=nagisa
Browse files Browse the repository at this point in the history
it makes no sense here, accidentally introduced in #30931

r? @dotdash
  • Loading branch information
bors committed Jan 18, 2016
2 parents 9d21aca + c02ba16 commit 50a8333
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/adt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/trans/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
7 changes: 3 additions & 4 deletions src/librustc_trans/trans/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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);
Expand All @@ -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)
}
}

Expand Down
3 changes: 1 addition & 2 deletions src/librustc_trans/trans/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 50a8333

Please sign in to comment.