Skip to content

Commit 208c8f5

Browse files
nagisaest31
authored andcommitted
Fix sign-extension in stage1 compiler
1 parent 0a481fe commit 208c8f5

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/librustc_trans/common.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -427,13 +427,14 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
427427
}
428428
}
429429

430-
pub fn C_big_integral(t: Type, u: u128) -> ValueRef {
430+
pub fn C_big_integral(t: Type, u: u128, sign_extend: bool) -> ValueRef {
431431
if ::std::mem::size_of::<u128>() == 16 {
432432
unsafe {
433433
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, &u as *const u128 as *const u64)
434434
}
435435
} else {
436-
C_integral(t, u as u64, false)
436+
// SNAP: remove after snapshot
437+
C_integral(t, u as u64, sign_extend)
437438
}
438439
}
439440

src/librustc_trans/mir/constant.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ impl<'tcx> Const<'tcx> {
7676
ConstVal::Integral(I16(v)) => C_integral(Type::i16(ccx), v as u64, true),
7777
ConstVal::Integral(I32(v)) => C_integral(Type::i32(ccx), v as u64, true),
7878
ConstVal::Integral(I64(v)) => C_integral(Type::i64(ccx), v as u64, true),
79-
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128),
79+
ConstVal::Integral(I128(v)) => C_big_integral(Type::i128(ccx), v as u128, true),
8080
ConstVal::Integral(Isize(v)) => {
8181
let i = v.as_i64(ccx.tcx().sess.target.int_type);
8282
C_integral(Type::int(ccx), i as u64, true)
@@ -85,7 +85,7 @@ impl<'tcx> Const<'tcx> {
8585
ConstVal::Integral(U16(v)) => C_integral(Type::i16(ccx), v as u64, false),
8686
ConstVal::Integral(U32(v)) => C_integral(Type::i32(ccx), v as u64, false),
8787
ConstVal::Integral(U64(v)) => C_integral(Type::i64(ccx), v, false),
88-
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v),
88+
ConstVal::Integral(U128(v)) => C_big_integral(Type::i128(ccx), v, false),
8989
ConstVal::Integral(Usize(v)) => {
9090
let u = v.as_u64(ccx.tcx().sess.target.uint_type);
9191
C_integral(Type::int(ccx), u, false)

0 commit comments

Comments
 (0)