22 #define DEBUG_TYPE "loweratomic" 113 bool Changed =
false;
116 if (
FenceInst *FI = dyn_cast<FenceInst>(Inst))
120 else if (
AtomicRMWInst *RMWI = dyn_cast<AtomicRMWInst>(Inst))
122 else if (
LoadInst *LI = dyn_cast<LoadInst>(Inst)) {
125 }
else if (
StoreInst *
SI = dyn_cast<StoreInst>(Inst)) {
134 bool Changed =
false;
159 auto PA = Impl.run(F, DummyFAM);
160 return !PA.areAllPreserved();
170 "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
This class represents lattice values for constants.
Value * CreateICmpULT(Value *LHS, Value *RHS, const Twine &Name="")
LoadInst * CreateLoad(Type *Ty, Value *Ptr, const char *Name)
Provided to resolve 'CreateLoad(Ty, Ptr, "...")' correctly, instead of converting the string to 'bool...
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
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.
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this store instruction.
*p = old >signed v ? old : v
iterator begin()
Instruction iterator methods.
Value * CreateNot(Value *V, const Twine &Name="")
void setAtomic(AtomicOrdering Ordering, SyncScope::ID SSID=SyncScope::System)
Sets the ordering constraint and the synchronization scope ID of this load instruction.
INITIALIZE_PASS(LowerAtomicLegacyPass, "loweratomic", "Lower atomic intrinsics to non-atomic form", false, false) Pass *llvm
BinOp getOperation() const
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()
Type * getType() const
All values are typed, get the type of this value.
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="")
static bool runOnFunction(Function &F, bool PostInlining)
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.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Iterator for intrusive lists based on ilist_node.
Pass * createLowerAtomicPass()
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)