Skip to content

Commit

Permalink
Rollup merge of rust-lang#39332 - nagisa:another-bigendian-128, r=eddyb
Browse files Browse the repository at this point in the history
Fix another endianness issue in i128 trans

Apparently LLVMArbitraryPrecisionInteger demands integers to be in low-endian 64-bytes, rather than host-endian 64-bytes. This is weird, and obviously, not documented. And rustc now works a teeny bit more on big endians.

r? @eddyb
  • Loading branch information
alexcrichton committed Jan 28, 2017
2 parents a5ff116 + b8036b6 commit 30ae115
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,8 @@ pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> 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)
let words = [u as u64, u.wrapping_shr(64) as u64];
llvm::LLVMConstIntOfArbitraryPrecision(t.to_ref(), 2, words.as_ptr())
}
} else {
// SNAP: remove after snapshot
Expand Down

0 comments on commit 30ae115

Please sign in to comment.