Currently, AtomicExpandPass will expand atomic instructions to an __atomic_*
libcall in the if the size is greater than MaxSizeInBitsSupported or the
alignment is less than the value's natural alignment. The only way a target
can influence this is by changing MaxSizeInBitsSupported, but this is a very
blunt instrument. A target might, for instance, want to always generate
libcalls for atomics less than the native word size but generate inline
lock-free code for word-sized atomics. If the library implementation is known
to be lock-free, the target as even greater flexibility such as choosing to
emit a libcall or not depending on wheter optimising for size.
The new TargetLowering::shouldExpandAtomicToLibCall makes this degree of
flexibility possible. The default implementation makes use of
MaxSizeInBitsSupported so there is no functional change for in-tree or
out-of-tree targets that don't implement their own
shouldExpandAtomicToLibCall.