[llvm] [AtomicExpandPass][NVPTX] Preserve atomic and volatile nature of emulated operations (PR #188361)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 1 05:22:46 PDT 2026
================
@@ -1163,6 +1164,22 @@ bool AtomicExpandImpl::expandPartwordCmpXchg(AtomicCmpXchgInst *CI) {
PHINode *Loaded_MaskOut = Builder.CreatePHI(PMV.WordType, 2);
Loaded_MaskOut->addIncoming(InitLoaded_MaskOut, BB);
+ // The initial load must be atomic with the same synchronization scope
+ // to avoid a data race with concurrent stores. If the instruction being
+ // emulated is volatile, issue a volatile load.
+ // addIncoming is done first so that expandAtomicLoadToLibcall's
+ // replaceAllUsesWith correctly updates the PHI incoming value.
+ InitLoaded->setVolatile(CI->isVolatile());
+ if (TLI->issueAtomicInitLoadForAtomicEmulation()) {
+ // TODO: Get rid of the target hook once all backends start issuing
+ // atomic loads.
----------------
arsenm wrote:
Just do the mechanical updates. This is how these sorts of cross backend changes go
https://github.com/llvm/llvm-project/pull/188361
More information about the llvm-commits
mailing list