llvm::buildCmpXchgValue

Emit IR to implement the given cmpxchg operation on values in registers, returning the new value.

Synopsis

Declared in <llvm/Transforms/Utils/LowerAtomic.h>

std::pair<Value*, Value*>
buildCmpXchgValue(
    IRBuilderBase& Builder,
    Value* Ptr,
    Value* Cmp,
    Value* Val,
    Align Alignment);

Return Value

A pair of the original loaded value and whether it equaled Cmp.

Parameters

NameDescription
BuilderIR builder used to emit the non-atomic cmpxchg sequence.
PtrPointer to the memory location being compared and exchanged.
CmpExpected value compared against the loaded contents of Ptr.
ValNew value stored to Ptr when the comparison succeeds.
AlignmentAlignment of the load and store to Ptr.