diff options
author | Renato Botelho <renato@netgate.com> | 2016-12-14 13:59:40 -0200 |
---|---|---|
committer | Renato Botelho <renato@netgate.com> | 2016-12-14 13:59:40 -0200 |
commit | cc9fac304cafadab4656653aa1a62fdad74b4e94 (patch) | |
tree | 43fee446af0c829986548dcbe6862d3ac31bae2e /contrib/llvm/lib | |
parent | 812767d2bb4e201b4f826fd31924d2cafb8fe0ae (diff) | |
parent | 6d3cdf0ab519f1b7bad6bd132eda48242f0ff7c8 (diff) | |
download | FreeBSD-src-cc9fac304cafadab4656653aa1a62fdad74b4e94.zip FreeBSD-src-cc9fac304cafadab4656653aa1a62fdad74b4e94.tar.gz |
Merge remote-tracking branch 'origin/stable/10' into devel
Diffstat (limited to 'contrib/llvm/lib')
-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()) |