From owner-svn-src-all@freebsd.org Sun Dec 11 19:58:15 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 03BB2C72BEC; Sun, 11 Dec 2016 19:58:15 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CB10B1625; Sun, 11 Dec 2016 19:58:14 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBBJwEoR011758; Sun, 11 Dec 2016 19:58:14 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBBJwDvN011757; Sun, 11 Dec 2016 19:58:13 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201612111958.uBBJwDvN011757@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Sun, 11 Dec 2016 19:58:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r309857 - in stable: 10/contrib/llvm/lib/Analysis 11/contrib/llvm/lib/Analysis 9/contrib/llvm/lib/Analysis X-SVN-Group: stable-11 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Dec 2016 19:58:15 -0000 Author: dim Date: Sun Dec 11 19:58:13 2016 New Revision: 309857 URL: https://svnweb.freebsd.org/changeset/base/309857 Log: 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 Modified: stable/11/contrib/llvm/lib/Analysis/LazyValueInfo.cpp Directory Properties: stable/11/ (props changed) Changes in other areas also in this revision: Modified: stable/10/contrib/llvm/lib/Analysis/LazyValueInfo.cpp stable/9/contrib/llvm/lib/Analysis/LazyValueInfo.cpp Directory Properties: stable/10/ (props changed) stable/9/contrib/llvm/ (props changed) Modified: stable/11/contrib/llvm/lib/Analysis/LazyValueInfo.cpp ============================================================================== --- stable/11/contrib/llvm/lib/Analysis/LazyValueInfo.cpp Sun Dec 11 19:50:39 2016 (r309856) +++ stable/11/contrib/llvm/lib/Analysis/LazyValueInfo.cpp Sun Dec 11 19:58:13 2016 (r309857) @@ -1203,8 +1203,27 @@ 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(V)) + return true; + return false; +} + Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB, Instruction *CxtI) { + // Bail out early if V is known not to be a Constant. + if (isKnownNonConstant(V)) + return nullptr; + const DataLayout &DL = BB->getModule()->getDataLayout(); LVILatticeVal Result = getCache(PImpl, AC, &DL, DT).getValueInBlock(V, BB, CxtI); @@ -1322,6 +1341,17 @@ LazyValueInfo::getPredicateOnEdge(unsign LazyValueInfo::Tristate LazyValueInfo::getPredicateAt(unsigned Pred, Value *V, Constant *C, Instruction *CxtI) { + // Is or is not NonNull are common predicates being queried. If + // isKnownNonNull can tell us the result of the predicate, we can + // return it quickly. But this is only a fastpath, and falling + // through would still be correct. + if (V->getType()->isPointerTy() && C->isNullValue() && + isKnownNonNull(V->stripPointerCasts())) { + if (Pred == ICmpInst::ICMP_EQ) + return LazyValueInfo::False; + else if (Pred == ICmpInst::ICMP_NE) + return LazyValueInfo::True; + } const DataLayout &DL = CxtI->getModule()->getDataLayout(); LVILatticeVal Result = getCache(PImpl, AC, &DL, DT).getValueAt(V, CxtI); Tristate Ret = getPredicateResult(Pred, C, Result, DL, TLI);