Skip to content

Commit

Permalink
do not assume anything about the top bits in llvm intrinsics receivin…
Browse files Browse the repository at this point in the history
…g i8/i16 values - while normally we can assume that the top bits are clear due to how LLVM creates the call, if the call is an ffi or constructed in a non-clang way (see rust-lang/rust#39119) then we must be careful
  • Loading branch information
kripken committed Jan 17, 2017
1 parent 62dfd0f commit 12c1945
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -951,15 +951,15 @@ LibraryManager.library = {
llvm_ctlz_i8: function(x, isZeroUndef) {
x = x | 0;
isZeroUndef = isZeroUndef | 0;
return (Math_clz32(x) | 0) - 24 | 0;
return (Math_clz32(x & 0xff) | 0) - 24 | 0;
},

llvm_ctlz_i16__asm: true,
llvm_ctlz_i16__sig: 'ii',
llvm_ctlz_i16: function(x, isZeroUndef) {
x = x | 0;
isZeroUndef = isZeroUndef | 0;
return (Math_clz32(x) | 0) - 16 | 0
return (Math_clz32(x & 0xffff) | 0) - 16 | 0
},

llvm_ctlz_i64__asm: true,
Expand Down

0 comments on commit 12c1945

Please sign in to comment.