This is an archive of the discontinued LLVM Phabricator instance.

Correctly generate invert xor value for Binary Atomics of int size > 64
ClosedPublic

Authored by jyu2 on Jun 29 2020, 6:24 PM.

Details

Summary

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.

Diff Detail

Event Timeline

jyu2 created this revision.Jun 29 2020, 6:24 PM
jyu2 added a subscriber: cfe-commits.
jfb accepted this revision.Jun 30 2020, 9:15 AM

This amused me.

This revision is now accepted and ready to land.Jun 30 2020, 9:15 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 7 2020, 10:21 AM