Update scalar pairs per review comments
This commit is contained in:
parent
e578976560
commit
557736befc
@ -18,7 +18,7 @@ use rustc_data_structures::indexed_vec::Idx;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
||||
use base;
|
||||
use common::{self, CodegenCx, C_null, C_undef, C_usize};
|
||||
use common::{CodegenCx, C_null, C_undef, C_usize};
|
||||
use builder::{Builder, MemFlags};
|
||||
use value::Value;
|
||||
use type_of::LayoutLlvmExt;
|
||||
@ -310,10 +310,6 @@ impl<'a, 'tcx> OperandValue {
|
||||
OperandValue::Pair(a, b) => {
|
||||
for (i, &x) in [a, b].iter().enumerate() {
|
||||
let llptr = bx.struct_gep(dest.llval, i as u64);
|
||||
// Make sure to always store i1 as i8.
|
||||
if common::val_ty(x) == Type::i1(bx.cx) {
|
||||
assert_eq!(common::val_ty(llptr), Type::i8p(bx.cx));
|
||||
}
|
||||
let val = base::from_immediate(bx, x);
|
||||
bx.store_with_flags(val, llptr, dest.align, flags);
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ use rustc::mir::tcx::PlaceTy;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use base;
|
||||
use builder::Builder;
|
||||
use common::{CodegenCx, C_undef, C_usize, C_u8, C_u32, C_uint, C_null, C_uint_big, val_ty};
|
||||
use common::{CodegenCx, C_undef, C_usize, C_u8, C_u32, C_uint, C_null, C_uint_big};
|
||||
use consts;
|
||||
use type_of::LayoutLlvmExt;
|
||||
use type_::Type;
|
||||
@ -128,10 +128,6 @@ impl<'a, 'tcx> PlaceRef<'tcx> {
|
||||
} else if let layout::Abi::ScalarPair(ref a, ref b) = self.layout.abi {
|
||||
let load = |i, scalar: &layout::Scalar| {
|
||||
let llptr = bx.struct_gep(self.llval, i as u64);
|
||||
// Make sure to always load i1 as i8.
|
||||
if scalar.is_bool() {
|
||||
assert_eq!(val_ty(llptr), Type::i8p(bx.cx));
|
||||
}
|
||||
let load = bx.load(llptr, self.align);
|
||||
scalar_load_metadata(load, scalar);
|
||||
if scalar.is_bool() {
|
||||
|
@ -363,7 +363,7 @@ impl<'tcx> LayoutLlvmExt<'tcx> for TyLayout<'tcx> {
|
||||
|
||||
// Make sure to return the same type `immediate_llvm_type` would when
|
||||
// dealing with an immediate pair. This means that `(bool, bool)` is
|
||||
// effectively represented as `{i8, i8}` in memory and `{i1, i1}` as an
|
||||
// effectively represented as `{i8, i8}` in memory and two `i1`s as an
|
||||
// immediate, just like `bool` is typically `i8` in memory and only `i1`
|
||||
// when immediate. We need to load/store `bool` as `i8` to avoid
|
||||
// crippling LLVM optimizations or triggering other LLVM bugs with `i1`.
|
||||
|
@ -38,3 +38,17 @@ pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) {
|
||||
// CHECK: or i1 %arg0.0, %arg0.1
|
||||
(a && b, a || b)
|
||||
}
|
||||
|
||||
// CHECK: define void @pair_branches(i1 zeroext %arg0.0, i1 zeroext %arg0.1)
|
||||
#[no_mangle]
|
||||
pub fn pair_branches((a, b): (bool, bool)) {
|
||||
// Make sure it can branch directly on the unpacked bool args
|
||||
// CHECK: br i1 %arg0.0
|
||||
if a {
|
||||
println!("Hello!");
|
||||
}
|
||||
// CHECK: br i1 %arg0.1
|
||||
if b {
|
||||
println!("Goodbye!");
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user