diff options
author | dim <dim@FreeBSD.org> | 2016-12-11 19:58:13 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2016-12-11 19:58:13 +0000 |
commit | 33726319e9fc70ba903ad27ef6e76ddfeb7386b1 (patch) | |
tree | 0f0402323bc4943395b0eea751ffa427d080feaf /contrib/llvm | |
parent | 884efc61f7391700d81bb717ea62d897524b2184 (diff) | |
download | FreeBSD-src-33726319e9fc70ba903ad27ef6e76ddfeb7386b1.zip FreeBSD-src-33726319e9fc70ba903ad27ef6e76ddfeb7386b1.tar.gz |
MFC r309722:
Pull in r281586 from upstream llvm trunk (by Wei Mi):
Add some shortcuts in LazyValueInfo to reduce compile time of
Correlated Value Propagation.
The patch is to partially fix PR10584. Correlated Value Propagation
queries LVI to check non-null for pointer params of each callsite. If
we know the def of param is an alloca instruction, we know it is
non-null and can return early from LVI. Similarly, CVP queries LVI to
check whether pointer for each mem access is constant. If the def of
the pointer is an alloca instruction, we know it is not a constant
pointer. These shortcuts can reduce the cost of CVP significantly.
Differential Revision: https://reviews.llvm.org/D18066
This significantly reduces memory usage and compilation time when
compiling a particular C++ source file of the graphics/colmap port.
PR: 215136
Diffstat (limited to 'contrib/llvm')
-rw-r--r-- | contrib/llvm/lib/Analysis/LazyValueInfo.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/contrib/llvm/lib/Analysis/LazyValueInfo.cpp b/contrib/llvm/lib/Analysis/LazyValueInfo.cpp index b6970af..dd0f4cc0 100644 --- a/contrib/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/contrib/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1033,7 +1033,26 @@ void LazyValueInfo::releaseMemory() { } } + +/// Returns true if we can statically tell that this value will never be a +/// "useful" constant. In practice, this means we've got something like an +/// alloca or a malloc call for which a comparison against a constant can +/// only be guarding dead code. Note that we are potentially giving up some +/// precision in dead code (a constant result) in favour of avoiding a +/// expensive search for a easily answered common query. +static bool isKnownNonConstant(Value *V) { + V = V->stripPointerCasts(); + // The return val of alloc cannot be a Constant. + if (isa<AllocaInst>(V)) + return true; + return false; +} + Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB) { + // Bail out early if V is known not to be a Constant. + if (isKnownNonConstant(V)) + return nullptr; + LVILatticeVal Result = getCache(PImpl).getValueInBlock(V, BB); if (Result.isConstant()) |