Skip to content

Commit 1abfc5c

Browse files
nagisaest31
authored andcommitted
Fix sign-extension in stage1 compiler
1 parent 526c505 commit 1abfc5c

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/librustc_trans/common.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -741,13 +741,14 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
741741
}
742742
}
743743

744-
pub fn C_big_integral(t: Type, u: u128) -> ValueRef {
744+
pub fn C_big_integral(t: Type, u: u128, sign_extend: bool) -> ValueRef {
745745
if ::std::mem::size_of::<u128>() == 16 {
746746
unsafe {
747747
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, &u as *const u128 as *const u64)
748748
}
749749
} else {
750-
C_integral(t, u as u64, false)
750+
// SNAP: remove after snapshot
751+
C_integral(t, u as u64, sign_extend)
751752
}
752753
}
753754

src/librustc_trans/mir/constant.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<'tcx> Const<'tcx> {
7878
ConstVal::Integral(I16(v)) => C_integral(Type::i16(ccx), v as u64, true),
7979
ConstVal::Integral(I32(v)) => C_integral(Type::i32(ccx), v as u64, true),
8080
ConstVal::Integral(I64(v)) => C_integral(Type::i64(ccx), v as u64, true),
81-
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128),
81+
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128, true),
8282
ConstVal::Integral(Isize(v)) => {
8383
let i = v.as_i64(ccx.tcx().sess.target.int_type);
8484
C_integral(Type::int(ccx), i as u64, true)
@@ -87,7 +87,7 @@ impl<'tcx> Const<'tcx> {
8787
ConstVal::Integral(U16(v)) => C_integral(Type::i16(ccx), v as u64, false),
8888
ConstVal::Integral(U32(v)) => C_integral(Type::i32(ccx), v as u64, false),
8989
ConstVal::Integral(U64(v)) => C_integral(Type::i64(ccx), v, false),
90-
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v),
90+
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v, false),
9191
ConstVal::Integral(Usize(v)) => {
9292
let u = v.as_u64(ccx.tcx().sess.target.uint_type);
9393
C_integral(Type::int(ccx), u, false)

0 commit comments

Comments
 (0)