Consider Scalar to be a bool only if its unsigned
This seems right, given that conceptually bools are unsigned, but the implications of this change may have more action at distance that I'm not sure how to exhaustively consider. For instance there are a number of cases where code attaches range metadata if `scalar.is_bool()` holds. Supposedly it would no longer be attached to the `repr(i8)` enums? Though I'm not sure why booleans are being special-cased here in the first place... Fixes #80556
This commit is contained in:
parent
b122908617
commit
915a04e2a4
|
@ -103,7 +103,12 @@ impl ArgAttributes {
|
|||
}
|
||||
|
||||
pub fn ext(&mut self, ext: ArgExtension) -> &mut Self {
|
||||
assert!(self.arg_ext == ArgExtension::None || self.arg_ext == ext);
|
||||
assert!(
|
||||
self.arg_ext == ArgExtension::None || self.arg_ext == ext,
|
||||
"cannot set {:?} when {:?} is already set",
|
||||
ext,
|
||||
self.arg_ext
|
||||
);
|
||||
self.arg_ext = ext;
|
||||
self
|
||||
}
|
||||
|
|
|
@ -682,7 +682,7 @@ pub struct Scalar {
|
|||
|
||||
impl Scalar {
|
||||
pub fn is_bool(&self) -> bool {
|
||||
if let Int(I8, _) = self.value { self.valid_range == (0..=1) } else { false }
|
||||
matches!(self.value, Int(I8, false)) && self.valid_range == (0..=1)
|
||||
}
|
||||
|
||||
/// Returns the valid range as a `x..y` range.
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
#![crate_type="lib"]
|
||||
|
||||
#[repr(i8)]
|
||||
pub enum Type {
|
||||
Type1 = 0,
|
||||
Type2 = 1
|
||||
}
|
||||
|
||||
// CHECK: define signext i8 @test()
|
||||
#[no_mangle]
|
||||
pub extern "C" fn test() -> Type {
|
||||
Type::Type1
|
||||
}
|
Loading…
Reference in New Issue