This is an archive of the discontinued LLVM Phabricator instance.

Fix __atomic_is_lock_free's return type.
Needs ReviewPublic

Authored by jyknight on Sep 13 2019, 3:01 PM.

Details

Reviewers
rsmith
Summary

It is specified to return a bool in GCC's documentation and
implementation, but the clang builtin says it returns an int. This
would be pretty much harmless, if it was just the builtin.

However, when clang translates the builtin into a libcall, it _also_
generates the libcall with an int return type, while the actual
library function in libatomic returns a bool.

This mismatch in return types results in an actual ABI mismatch and
thus incorrect results (interpreting false return value as true) on at
least x86_64.

Event Timeline

jyknight created this revision.Sep 13 2019, 3:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 13 2019, 3:01 PM