orrectly generate invert xor value for Binary Atomics of int size > 64
authorJennifer Yu <jennifer.yu@intel.com>
Tue, 7 Jul 2020 16:27:20 +0000 (09:27 -0700)
committerJennifer Yu <jennifer.yu@intel.com>
Tue, 7 Jul 2020 17:20:14 +0000 (10:20 -0700)
commit6cf0dac1ca3fd56c51f6a60f0be01cc25a1a2c6a
treea900ab67efcb50b49bab1014269361f0e2d1200e
parent8a8d6e2b727112fafc52477acaf25affb62b6e65
orrectly generate invert xor value for Binary Atomics of int size > 64

When using __sync_nand_and_fetch with __int128, a problem is found that
the wrong value for the 'invert' value gets emitted to the xor in case
where the int size is greater than 64 bits.

This is because uses of llvm::ConstantInt::get which zero extends the
greater than 64 bits, so instead -1 that we require, it end up
getting 18446744073709551615

This patch replaces the call to llvm::ConstantInt::get with the call
to llvm::Constant::getAllOnesValue which works for all integer types.

Reviewers: jfp, erichkeane, rjmccall, hfinkel

Differential Revision: https://reviews.llvm.org/D82832
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/Atomics.c