Add methods for checking for full ranges to Scalar and WrappingRange
Move *_max methods back to util change to inline instead of inline(always) Remove valid_range_exclusive from scalar Use WrappingRange instead implement always_valid_for in a safer way Fix accidental edit
This commit is contained in:
@@ -20,7 +20,7 @@ use rustc_middle::ty::{self, Instance, Ty, TypeFoldable};
|
||||
use rustc_span::source_map::Span;
|
||||
use rustc_span::{sym, Symbol};
|
||||
use rustc_target::abi::call::{ArgAbi, FnAbi, PassMode};
|
||||
use rustc_target::abi::{self, HasDataLayout};
|
||||
use rustc_target::abi::{self, HasDataLayout, WrappingRange};
|
||||
use rustc_target::spec::abi::Abi;
|
||||
|
||||
/// Used by `FunctionCx::codegen_terminator` for emitting common patterns
|
||||
@@ -1104,7 +1104,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
llval = bx.load(bx.backend_type(arg.layout), llval, align);
|
||||
if let abi::Abi::Scalar(ref scalar) = arg.layout.abi {
|
||||
if scalar.is_bool() {
|
||||
bx.range_metadata(llval, 0..2);
|
||||
bx.range_metadata(llval, &WrappingRange { start: 0, end: 1 });
|
||||
}
|
||||
}
|
||||
// We store bools as `i8` so we need to truncate to `i1`.
|
||||
|
||||
@@ -308,8 +308,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
|
||||
// then `i1 1` (i.e., E::B) is effectively `i8 -1`.
|
||||
signed = !scalar.is_bool() && s;
|
||||
|
||||
let er = scalar.valid_range_exclusive(bx.cx());
|
||||
if er.end != er.start
|
||||
if !scalar.is_always_valid_for(bx.cx())
|
||||
&& scalar.valid_range.end >= scalar.valid_range.start
|
||||
{
|
||||
// We want `table[e as usize ± k]` to not
|
||||
|
||||
Reference in New Issue
Block a user