Skip to content

Commit

Permalink
Fix sign-extension in stage1 compiler
Browse files Browse the repository at this point in the history
  • Loading branch information
nagisa authored and est31 committed Dec 20, 2016
1 parent 526c505 commit 1abfc5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,14 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
}
}

pub fn C_big_integral(t: Type, u: u128) -> ValueRef {
pub fn C_big_integral(t: Type, u: u128, sign_extend: bool) -> ValueRef {
if ::std::mem::size_of::<u128>() == 16 {
unsafe {
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, &u as *const u128 as *const u64)
}
} else {
C_integral(t, u as u64, false)
// SNAP: remove after snapshot
C_integral(t, u as u64, sign_extend)
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_trans/mir/constant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ impl<'tcx> Const<'tcx> {
ConstVal::Integral(I16(v)) => C_integral(Type::i16(ccx), v as u64, true),
ConstVal::Integral(I32(v)) => C_integral(Type::i32(ccx), v as u64, true),
ConstVal::Integral(I64(v)) => C_integral(Type::i64(ccx), v as u64, true),
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128),
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128, true),
ConstVal::Integral(Isize(v)) => {
let i = v.as_i64(ccx.tcx().sess.target.int_type);
C_integral(Type::int(ccx), i as u64, true)
Expand All @@ -87,7 +87,7 @@ impl<'tcx> Const<'tcx> {
ConstVal::Integral(U16(v)) => C_integral(Type::i16(ccx), v as u64, false),
ConstVal::Integral(U32(v)) => C_integral(Type::i32(ccx), v as u64, false),
ConstVal::Integral(U64(v)) => C_integral(Type::i64(ccx), v, false),
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v),
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v, false),
ConstVal::Integral(Usize(v)) => {
let u = v.as_u64(ccx.tcx().sess.target.uint_type);
C_integral(Type::int(ccx), u, false)
Expand Down

0 comments on commit 1abfc5c

Please sign in to comment.