23 #define DEBUG_TYPE "loweratomic"
114 bool Changed =
false;
117 if (
FenceInst *FI = dyn_cast<FenceInst>(Inst))
121 else if (
AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(Inst))
123 else if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
126 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
135 bool Changed =
false;
157 bool runOnFunction(
Function &
F)
override {
161 auto PA = Impl.run(F, DummyFAM);
162 return !PA.areAllPreserved();
172 "Lower atomic intrinsics to non-atomic form",
false,
false)
PreservedAnalyses run(Function &F, FunctionAnalysisManager &)
Pass interface - Implemented by all 'passes'.
SymbolTableList< Instruction >::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
*p = old <signed v ? old : v
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
Value * CreateXor(Value *LHS, Value *RHS, const Twine &Name="")
An instruction for ordering other memory operations.
an instruction that atomically checks whether a specified value is in a memory location, and, if it is, stores a new value there.
Value * CreateICmpSLT(Value *LHS, Value *RHS, const Twine &Name="")
static bool runOnBasicBlock(BasicBlock &BB)
*p = old <unsigned v ? old : v
static bool lowerAtomics(Function &F)
static bool LowerLoadInst(LoadInst *LI)
*p = old >unsigned v ? old : v
INITIALIZE_PASS(LowerAtomicLegacyPass,"loweratomic","Lower atomic intrinsics to non-atomic form", false, false) Pass *llvm
Value * getNewValOperand()
An instruction for reading from memory.
an instruction that atomically reads a memory location, combines it with another value, and then stores the result back.
static bool LowerFenceInst(FenceInst *FI)
A pass that lowers atomic intrinsic into non-atomic intrinsics.
*p = old >signed v ? old : v
iterator begin()
Instruction iterator methods.
Value * CreateNot(Value *V, const Twine &Name="")
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
Value * CreateAdd(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
StoreInst * CreateStore(Value *Val, Value *Ptr, bool isVolatile=false)
Value * getPointerOperand()
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
static bool LowerStoreInst(StoreInst *SI)
Value * CreateSub(Value *LHS, Value *RHS, const Twine &Name="", bool HasNUW=false, bool HasNSW=false)
An instruction for storing to memory.
void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
Value * CreateOr(Value *LHS, Value *RHS, const Twine &Name="")
LoadInst * CreateLoad(Value *Ptr, const char *Name)
A set of analyses that are preserved following a run of a transformation pass.
LLVM Basic Block Representation.
Value * getCompareOperand()
Value * CreateSelect(Value *C, Value *True, Value *False, const Twine &Name="", Instruction *MDFrom=nullptr)
static bool LowerAtomicRMWInst(AtomicRMWInst *RMWI)
void initializeLowerAtomicLegacyPassPass(PassRegistry &)
FunctionPass class - This class is used to implement most global optimizations.
Value * CreateICmpEQ(Value *LHS, Value *RHS, const Twine &Name="")
static UndefValue * get(Type *T)
Static factory methods - Return an 'undef' object of the specified type.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
void setAtomic(AtomicOrdering Ordering, SynchronizationScope SynchScope=CrossThread)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator for intrusive lists based on ilist_node.
Type * getType() const
All values are typed, get the type of this value.
Pass * createLowerAtomicPass()
BinOp getOperation() const
Value * getPointerOperand()
Value * CreateAnd(Value *LHS, Value *RHS, const Twine &Name="")
LLVM Value Representation.
A container for analyses that lazily runs them and caches their results.
Value * CreateInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > Idxs, const Twine &Name="")
static bool LowerAtomicCmpXchgInst(AtomicCmpXchgInst *CXI)