This was reverted in https://github.com/llvm/llvm-project/pull/110969
due to a failure on aarch64.
Weirdly aarch64 (but apparently not x86?) has a spurious phi
instruction. flang -fc1 -emit-llvm will run midle-end optimization
passes. Presumably one of those is behaving differently on different
targets. I have adapted the test to work correctly on aarch64.
The difference is in the RUN lines and the atomic exit block.
An integration test added in #92364 causes aarch64 buildbot failures.
Reverting the same. The relevant functionality added in #92364 is still
tested by the MLIR tests added in that PR, which pass on the relevant
aarch64 builds.
This patch adds functionality to emit relevant libcalls in case
atomicrmw instruction can not be emitted (for instance, in case of
complex types). The IRBuilder is modified to directly emit __atomic_load
and __atomic_compare_exchange libcalls. The added functions follow a
similar codegen path as Clang, so that LLVM Flang generates almost
similar IR as Clang.
Fixes https://github.com/llvm/llvm-project/issues/83760 and
https://github.com/llvm/llvm-project/issues/75138
Co-authored-by: Michael Kruse <llvm-project@meinersbur.de>