[flang-commits] [flang] [llvm] [mlir] [OpenMPIRBuilder] Emit __atomic_load and __atomic_compare_exchange libcalls for complex types in atomic update (PR #92364)

Michael Kruse via flang-commits flang-commits at lists.llvm.org
Fri Sep 20 02:31:35 PDT 2024


Meinersbur wrote:

One of other proposals was to preliminarily add `emitAtomicCompareExchangeBuiltin` from https://github.com/llvm/llvm-project/pull/101966 for use in OpenMPIRBuilder only (potentially simplified by removing options that OpenMPIRBuilder does not need). It could be later moved to LLVMFrontendAtomic once there is agreement what the generalized interface should be.

Check for the existence of support of `__atomic_compare_exchange` exists in `BuildLibCall.cpp` by querying TargetLibraryInfo. But it is too late in the compilation stage to emit an error, so they only sensible thing to do at this point is calling `error:report_fatal_error` like AtomicExpandPass does (there is no legal fallback behaviour). Proper handling would be during semantic analysis and emitting diagnostic which would be a completely different code path. Clang's CGAtomic doesn't do so either and is happy to emit `__atomic_compare_exchange` regardless whether the target supports it or not, so I think it is acceptable to not do this in Flang either for now. The user will see a link error. It even made it into [some unittests](https://github.com/llvm/llvm-project/blob/3c83102f0615c7d66f6df698ca472ddbf0e9483d/llvm/test/Transforms/AtomicExpand/AMDGPU/expand-atomicrmw-fp-vector.ll#L25). 

https://github.com/llvm/llvm-project/pull/92364


More information about the flang-commits mailing list