diff options
author | Dan Gohman <gohman@apple.com> | 2010-11-10 20:37:15 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-11-10 20:37:15 +0000 |
commit | 075fb5d68fcb55d26e44c48f07dfdbbfa21ccb2a (patch) | |
tree | bd2ac0b33edd3125d8741077ff4a5c274276b35e /include/llvm/Analysis | |
parent | af3d38f70ebba9fec0048c2540dbdf0168d280d2 (diff) | |
download | llvm-075fb5d68fcb55d26e44c48f07dfdbbfa21ccb2a.tar.gz llvm-075fb5d68fcb55d26e44c48f07dfdbbfa21ccb2a.tar.bz2 llvm-075fb5d68fcb55d26e44c48f07dfdbbfa21ccb2a.tar.xz |
Enhance GVN to do more precise alias queries for non-local memory
references. For example, this allows gvn to eliminate the load in
this example:
void foo(int n, int* p, int *q) {
p[0] = 0;
p[1] = 1;
if (n) {
*q = p[0];
}
}
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@118714 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Analysis')
-rw-r--r-- | include/llvm/Analysis/AliasAnalysis.h | 6 | ||||
-rw-r--r-- | include/llvm/Analysis/MemoryDependenceAnalysis.h | 15 |
2 files changed, 11 insertions, 10 deletions
diff --git a/include/llvm/Analysis/AliasAnalysis.h b/include/llvm/Analysis/AliasAnalysis.h index 17abae4eb9..302204e41b 100644 --- a/include/llvm/Analysis/AliasAnalysis.h +++ b/include/llvm/Analysis/AliasAnalysis.h @@ -107,6 +107,12 @@ public: return Copy; } + Location getWithNewSize(uint64_t NewSize) const { + Location Copy(*this); + Copy.Size = NewSize; + return Copy; + } + Location getWithoutTBAATag() const { Location Copy(*this); Copy.TBAATag = 0; diff --git a/include/llvm/Analysis/MemoryDependenceAnalysis.h b/include/llvm/Analysis/MemoryDependenceAnalysis.h index b5c68f6833..c1a1536037 100644 --- a/include/llvm/Analysis/MemoryDependenceAnalysis.h +++ b/include/llvm/Analysis/MemoryDependenceAnalysis.h @@ -227,11 +227,14 @@ namespace llvm { BBSkipFirstBlockPair Pair; /// NonLocalDeps - The results of the query for each relevant block. NonLocalDepInfo NonLocalDeps; + /// 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. - MDNode *TBAATag; + const MDNode *TBAATag; - NonLocalPointerInfo() : TBAATag(0) {} + NonLocalPointerInfo() : Size(0), TBAATag(0) {} }; /// CachedNonLocalPointerInfo - This map stores the cached results of doing @@ -315,14 +318,6 @@ namespace llvm { bool isLoad, BasicBlock *BB, SmallVectorImpl<NonLocalDepResult> &Result); - /// getNonLocalPointerDependence - A convenience wrapper. - void getNonLocalPointerDependency(Value *Pointer, bool isLoad, - BasicBlock *BB, - SmallVectorImpl<NonLocalDepResult> &Result){ - return getNonLocalPointerDependency(AliasAnalysis::Location(Pointer), - isLoad, BB, Result); - } - /// removeInstruction - Remove an instruction from the dependence analysis, /// updating the dependence of instructions that previously depended on it. void removeInstruction(Instruction *InstToRemove); |