Skip to content

Commit

Permalink
Fix change of behaviour found by @dotdash
Browse files Browse the repository at this point in the history
  • Loading branch information
nox committed Apr 24, 2018
1 parent ac13722 commit 555d16e
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 7 additions & 7 deletions src/librustc_trans/abi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1056,16 +1056,16 @@ impl<'a, 'tcx> FnType<'tcx> {
_ => {}
}
if let layout::Abi::Scalar(ref scalar) = self.ret.layout.abi {
if let Some(range) = scalar.range_metadata(bx.cx) {
// If the value is a boolean, the range is 0..2 and that ultimately
// become 0..0 when the type becomes i1, which would be rejected
// by the LLVM verifier.
match scalar.value {
layout::Int(..) if !scalar.is_bool() => {
// If the value is a boolean, the range is 0..2 and that ultimately
// become 0..0 when the type becomes i1, which would be rejected
// by the LLVM verifier.
match scalar.value {
layout::Int(..) if !scalar.is_bool() => {
if let Some(range) = scalar.range_metadata(bx.cx) {
bx.range_metadata(callsite, range);
}
_ => {}
}
_ => {}
}
}
for arg in &self.args {
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#![allow(unused_attributes)]
#![feature(libc)]
#![feature(quote)]
#![feature(range_contains)]
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
#![feature(optin_builtin_traits)]
Expand Down
15 changes: 8 additions & 7 deletions src/librustc_trans/mir/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,17 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
}

let scalar_load_metadata = |load, scalar: &layout::Scalar| {
if let Some(range) = scalar.range_metadata(bx.cx) {
match scalar.value {
layout::Int(..) => {
match scalar.value {
layout::Int(..) => {
if let Some(range) = scalar.range_metadata(bx.cx) {
bx.range_metadata(load, range);
}
layout::Pointer if 0 < range.start && range.start < range.end => {
bx.nonnull_metadata(load);
}
_ => {}
}
layout::Pointer
if (1..scalar.valid_range.end).contains(&scalar.valid_range.start) => {
bx.nonnull_metadata(load);
}
_ => {}
}
};

Expand Down

0 comments on commit 555d16e

Please sign in to comment.