This is an archive of the discontinued LLVM Phabricator instance.

Fix typos in compiler-rt/lib/builtins/atomic.c
ClosedPublic

Authored by xingxue on Mar 11 2019, 12:50 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

xingxue created this revision.Mar 11 2019, 12:50 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 11 2019, 12:50 PM
Herald added subscribers: Restricted Project, jdoerfert, jfb, dberris. · View Herald Transcript
jfb accepted this revision.Mar 11 2019, 1:32 PM
jfb added subscribers: theraven, t.p.northover.

How did this ever work?

This revision is now accepted and ready to land.Mar 11 2019, 1:32 PM

This leaves me wondering where the tests for this file are.

compiler-rt/lib/builtins/atomic.c
137 ↗(On Diff #190138)

Is IS_LOCK_FREE_1 omitted on purpose?

142 ↗(On Diff #190138)

The LOCK_FREE_ACTION is not supposed to fall-through to here. I am not sure the change is helpful (and it may reduce the ability of compiler warnings to catch bad definitions of LOCK_FREE_ACTION).

compiler-rt/lib/builtins/atomic.c
137 ↗(On Diff #190138)

__atomic_compare_exchange_c is lockful for 1-byte size regardless of platform support. A use of __atomic_store_1 is potentially lock-free depending on platform support. It is therefore possible for an __atomic_store_1 to violate the locking performed by __atomic_compare_exchange_c. This can potentially manifest as the __atomic_store_1 being never observed by the thread performing __atomic_compare_exchange_c.

xingxue marked 2 inline comments as done.Mar 13 2019, 12:15 PM
xingxue added inline comments.
compiler-rt/lib/builtins/atomic.c
137 ↗(On Diff #190138)

I think there should be a case for 1 byte as well. Will add:

case 1:\
  if (IS_LOCK_FREE_1) {\
    LOCK_FREE_ACTION(uint8_t);\
  }\
  break; \
142 ↗(On Diff #190138)

LOCK_FREE_ACTION is not supposed to fall-through. However, when IS_LOCK_FREE_* is false, the 'if' statement will fall-through.

xingxue updated this revision to Diff 190827.Mar 15 2019, 8:11 AM

Address review comments:

  • Added a case for 1 byte to macro LOCK_FREE_CASES.
xingxue marked 3 inline comments as done.Mar 15 2019, 8:13 AM
This revision was automatically updated to reflect the committed changes.