#define LLVM_ANALYSIS_MEMORYDEPENDENCEANALYSIS_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/OwningPtr.h"
#include "llvm/ADT/PointerIntPair.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/PredIteratorCache.h"
#include "llvm/IR/ValueHandle.h"
#include "llvm/Pass.h"
class Instruction;
class CallSite;
class AliasAnalysis;
- class DataLayout;
+ class AssumptionCache;
class MemoryDependenceAnalysis;
class PredIteratorCache;
class DominatorTree;
PairTy Value;
explicit MemDepResult(PairTy V) : Value(V) {}
public:
- MemDepResult() : Value(0, Invalid) {}
+ MemDepResult() : Value(nullptr, Invalid) {}
/// get methods: These are static ctor methods for creating various
/// MemDepResult kinds.
/// getInst() - If this is a normal dependency, return the instruction that
/// is depended on. Otherwise, return null.
Instruction *getInst() const {
- if (Value.getInt() == Other) return NULL;
+ if (Value.getInt() == Other) return nullptr;
return Value.getPointer();
}
/// Size - The maximum size of the dereferences of the
/// pointer. May be UnknownSize if the sizes are unknown.
uint64_t Size;
- /// TBAATag - The TBAA tag associated with dereferences of the
- /// pointer. May be null if there are no tags or conflicting tags.
- const MDNode *TBAATag;
+ /// AATags - The AA tags associated with dereferences of the
+ /// pointer. The members may be null if there are no tags or
+ /// conflicting tags.
+ AAMDNodes AATags;
- NonLocalPointerInfo() : Size(AliasAnalysis::UnknownSize), TBAATag(0) {}
+ NonLocalPointerInfo() : Size(MemoryLocation::UnknownSize) {}
};
/// CachedNonLocalPointerInfo - This map stores the cached results of doing
/// Current AA implementation, just a cache.
AliasAnalysis *AA;
- const DataLayout *DL;
DominatorTree *DT;
- OwningPtr<PredIteratorCache> PredCache;
+ AssumptionCache *AC;
+ const TargetLibraryInfo *TLI;
+ PredIteratorCache PredCache;
+
public:
MemoryDependenceAnalysis();
- ~MemoryDependenceAnalysis();
+ ~MemoryDependenceAnalysis() override;
static char ID;
/// Pass Implementation stuff. This doesn't do any analysis eagerly.
- bool runOnFunction(Function &);
+ bool runOnFunction(Function &) override;
/// Clean up memory in between runs
- void releaseMemory();
+ void releaseMemory() override;
/// getAnalysisUsage - Does not modify anything. It uses Value Numbering
/// and Alias Analysis.
///
- virtual void getAnalysisUsage(AnalysisUsage &AU) const;
+ void getAnalysisUsage(AnalysisUsage &AU) const override;
/// getDependency - Return the instruction on which a memory operation
/// depends. See the class comment for more details. It is illegal to call
/// getNonLocalPointerDependency - Perform a full dependency query for an
- /// access to the specified (non-volatile) memory location, returning the
- /// set of instructions that either define or clobber the value.
+ /// access to the QueryInst's specified memory location, returning the set
+ /// of instructions that either define or clobber the value.
+ ///
+ /// Warning: For a volatile query instruction, the dependencies will be
+ /// accurate, and thus usable for reordering, but it is never legal to
+ /// remove the query instruction.
///
- /// This method assumes the pointer has a "NonLocal" dependency within BB.
- void getNonLocalPointerDependency(const AliasAnalysis::Location &Loc,
- bool isLoad, BasicBlock *BB,
+ /// This method assumes the pointer has a "NonLocal" dependency within
+ /// QueryInst's parent basic block.
+ void getNonLocalPointerDependency(Instruction *QueryInst,
SmallVectorImpl<NonLocalDepResult> &Result);
/// removeInstruction - Remove an instruction from the dependence analysis,
///
/// Note that this is an uncached query, and thus may be inefficient.
///
- MemDepResult getPointerDependencyFrom(const AliasAnalysis::Location &Loc,
+ MemDepResult getPointerDependencyFrom(const MemoryLocation &Loc,
bool isLoad,
BasicBlock::iterator ScanIt,
BasicBlock *BB,
- Instruction *QueryInst = 0);
-
+ Instruction *QueryInst = nullptr);
/// getLoadLoadClobberFullWidthSize - This is a little bit of analysis that
/// looks at a memory location for a load (specified by MemLocBase, Offs,
static unsigned getLoadLoadClobberFullWidthSize(const Value *MemLocBase,
int64_t MemLocOffs,
unsigned MemLocSize,
- const LoadInst *LI,
- const DataLayout &DL);
+ const LoadInst *LI);
private:
MemDepResult getCallSiteDependencyFrom(CallSite C, bool isReadOnlyCall,
BasicBlock::iterator ScanIt,
BasicBlock *BB);
- bool getNonLocalPointerDepFromBB(const PHITransAddr &Pointer,
- const AliasAnalysis::Location &Loc,
- bool isLoad, BasicBlock *BB,
+ bool getNonLocalPointerDepFromBB(Instruction *QueryInst,
+ const PHITransAddr &Pointer,
+ const MemoryLocation &Loc, bool isLoad,
+ BasicBlock *BB,
SmallVectorImpl<NonLocalDepResult> &Result,
- DenseMap<BasicBlock*, Value*> &Visited,
+ DenseMap<BasicBlock *, Value *> &Visited,
bool SkipFirstBlock = false);
- MemDepResult GetNonLocalInfoForBlock(const AliasAnalysis::Location &Loc,
- bool isLoad, BasicBlock *BB,
- NonLocalDepInfo *Cache,
+ MemDepResult GetNonLocalInfoForBlock(Instruction *QueryInst,
+ const MemoryLocation &Loc, bool isLoad,
+ BasicBlock *BB, NonLocalDepInfo *Cache,
unsigned NumSortedEntries);
void RemoveCachedNonLocalPointerDependencies(ValueIsLoadPair P);