aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/Analysis/MemoryDependenceAnalysis.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-12-15 03:35:32 +0000
committerChris Lattner <sabre@nondot.org>2008-12-15 03:35:32 +0000
commit9e59c64c14cfe55e7cc9086c6bff8cfeecac361e (patch)
treebeb35f47a4da2768af1f2b6aecbcd93c0ea438b4 /include/llvm/Analysis/MemoryDependenceAnalysis.h
parent255dafc5de1e0e15ccebc9f5947330833008374a (diff)
downloadexternal_llvm-9e59c64c14cfe55e7cc9086c6bff8cfeecac361e.zip
external_llvm-9e59c64c14cfe55e7cc9086c6bff8cfeecac361e.tar.gz
external_llvm-9e59c64c14cfe55e7cc9086c6bff8cfeecac361e.tar.bz2
Implement initial support for PHI translation in memdep. This means that
memdep keeps track of how PHIs affect the pointer in dep queries, which allows it to eliminate the load in cases like rle-phi-translate.ll, which basically end up being: BB1: X = load P br BB3 BB2: Y = load Q br BB3 BB3: R = phi [P] [Q] load R turning "load R" into a phi of X/Y. In addition to additional exposed opportunities, this makes memdep safe in many cases that it wasn't before (which is required for load PRE) and also makes it substantially more efficient. For example, consider: bb1: // has many predecessors. P = some_operator() load P In this example, previously memdep would scan all the predecessors of BB1 to see if they had something that would mustalias P. In some cases (e.g. test/Transforms/GVN/rle-must-alias.ll) it would actually find them and end up eliminating something. In many other cases though, it would scan and not find anything useful. MemDep now stops at a block if the pointer is defined in that block and cannot be phi translated to predecessors. This causes it to miss the (rare) cases like rle-must-alias.ll, but makes it faster by not scanning tons of stuff that is unlikely to be useful. For example, this speeds up GVN as a whole from 3.928s to 2.448s (60%)!. IMO, scalar GVN should be enhanced to simplify the rle-must-alias pointer base anyway, which would allow the loads to be eliminated. In the future, this should be enhanced to phi translate through geps and bitcasts as well (as indicated by FIXMEs) making memdep even more powerful. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61022 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis/MemoryDependenceAnalysis.h')
-rw-r--r--include/llvm/Analysis/MemoryDependenceAnalysis.h17
1 files changed, 12 insertions, 5 deletions
diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h
index 8a5b07e..ac92b90 100644
--- a/include/llvm/Analysis/MemoryDependenceAnalysis.h
+++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h
@@ -156,12 +156,18 @@ namespace llvm {
/// ValueIsLoadPair - This is a pair<Value*, bool> where the bool is true if
/// the dependence is a read only dependence, false if read/write.
typedef PointerIntPair<Value*, 1, bool> ValueIsLoadPair;
-
+
+ /// BBSkipFirstBlockPair - This pair is used when caching information for a
+ /// block. If the pointer is null, the cache value is not a full query that
+ /// starts at the specified block. If non-null, the bool indicates whether
+ /// or not the contents of the block was skipped.
+ typedef PointerIntPair<BasicBlock*, 1, bool> BBSkipFirstBlockPair;
+
/// CachedNonLocalPointerInfo - This map stores the cached results of doing
/// a pointer lookup at the bottom of a block. The key of this map is the
/// pointer+isload bit, the value is a list of <bb->result> mappings.
- typedef DenseMap<ValueIsLoadPair,
- std::pair<BasicBlock*, NonLocalDepInfo> > CachedNonLocalPointerInfo;
+ typedef DenseMap<ValueIsLoadPair, std::pair<BBSkipFirstBlockPair,
+ NonLocalDepInfo> > CachedNonLocalPointerInfo;
CachedNonLocalPointerInfo NonLocalPointerDeps;
// A map from instructions to their non-local pointer dependencies.
@@ -259,10 +265,11 @@ namespace llvm {
MemDepResult getCallSiteDependencyFrom(CallSite C, bool isReadOnlyCall,
BasicBlock::iterator ScanIt,
BasicBlock *BB);
- void getNonLocalPointerDepFromBB(Value *Pointer, uint64_t Size,
+ bool getNonLocalPointerDepFromBB(Value *Pointer, uint64_t Size,
bool isLoad, BasicBlock *BB,
SmallVectorImpl<NonLocalDepEntry> &Result,
- SmallPtrSet<BasicBlock*, 64> &Visited);
+ DenseMap<BasicBlock*, Value*> &Visited,
+ bool SkipFirstBlock = false);
MemDepResult GetNonLocalInfoForBlock(Value *Pointer, uint64_t PointeeSize,
bool isLoad, BasicBlock *BB,
NonLocalDepInfo *Cache,