Page MenuHomePhabricator

[atomics] New warning -Watomic-libcall when atomic operation expands to a library call
Needs ReviewPublic

Authored by sdardis on Sep 12 2016, 2:18 AM.

Details

Reviewers
joerg
Summary

Targets typically support atomics that are word sized (e.g. 32 or 64 bit) or
half word sized (e.g. 32 bit on 64 bit systems). For larger sizes, some
targets can perform them directly (x86, ARM), other must expand them into
a library call. This patch adds the optional warning -Watomic-libcall which
warns when a atomic operation cannot be expanded inline and must use a
library call.

Diff Detail

Event Timeline

sdardis updated this revision to Diff 70982.Sep 12 2016, 2:18 AM
sdardis retitled this revision from to [atomics] New warning -Watomic-libcall when atomic operation expands to a library call .
sdardis updated this object.
sdardis added a subscriber: cfe-commits.
joerg added a subscriber: joerg.Sep 13 2016, 10:38 AM

While I agree with the general sentiment, the check doesn't work at all. For example, ARMv4 always has to use libcalls. It's not even true that libcalls are slow, i.e. on true non-parallel architectures, the libcall can be as simple as a restartable atomic sequence and is almost cost free beyond the function call overhead.

More precisely, this should re-use the logic from __atomic_is_lock_free and not reinvent it.

sdardis updated this revision to Diff 71507.Sep 16 2016, 2:10 AM
sdardis edited edge metadata.

Update comment and test for atomic expansion.

vkalintiris edited reviewers, added: joerg; removed: vkalintiris.Sep 20 2016, 8:36 AM
vkalintiris added a subscriber: vkalintiris.

I removed myself from the reviewers because I'm not quite familiar with this area. @joerg I added you as reviewer because you've already commented, feel free to undo my change if you don't have time to review this.