On SystemZ, int128 is aligned to only 8 bytes per the ABI, while 128 bit atomic ISA instructions exist with the requirement of alignment to 16 bytes. "sync" builtins in Clang are however always emitted as atomicrmw instructions which require a natural alignment of the address. This could then result in the situation where the value is aligned to only 8 bytes but an atomicrmw is emitted with an added incorrect alignment value of 16.
This patch checks that all values used with __sync builtins are naturally aligned, or else an error message is emitted.
I first made this a SystemZ specific check for 16 byte values, but it makes sense generally as well, so I changed that patch to always do the check. This is done at the point of emission (CGBuiltin.cpp) in order to be able to inspect the alignment of the value.