[PATCH] D17950: Implement is_always_lock_free

James Y Knight via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 17 10:17:22 PDT 2016


On Thu, Mar 17, 2016 at 12:55 PM, Craig, Ben <ben.craig at codeaurora.org>
wrote:

> I know that MIPS does that, and an out-of-tree implementation of hexagon
> implements 1-byte cmpxchg in terms of the 4-byte version. The emulation
> code isn't particularly small, and it seems reasonable to make it a libcall.


That's fine. Either do it inline or via an out-of-line version of the same
code, in a libcall. Either way acts the same, that is something that the
target backend can decide to do whenever it wants.

The important property for Clang is that it know whether it's lock-free or
not. And I don't believe there's any reason to use a mutex to implement a
1-byte ,cmpxchg on a platform with a 4-byte cmpxchg instruction available.

  The emulation code seems sketchy from a correctness perspective, as you
> end up generating unsolicited loads and stores on adjacent bytes.


I disagree. I do not see how expanding a subword cmpxchg into a
word-size-and-aligned cmpxchg could possibly cause a problem.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160317/abace087/attachment.html>


More information about the cfe-commits mailing list