From owner-svn-src-projects@freebsd.org Thu Feb 2 23:01:31 2017 Return-Path: Delivered-To: svn-src-projects@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 2A094CCECEB for ; Thu, 2 Feb 2017 23:01:31 +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 D5A6412EC; Thu, 2 Feb 2017 23:01:30 +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 v12N1Tov032358; Thu, 2 Feb 2017 23:01:29 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v12N1T9k032357; Thu, 2 Feb 2017 23:01:29 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201702022301.v12N1T9k032357@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 2 Feb 2017 23:01:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r313110 - projects/clang400-import/contrib/llvm/lib/Analysis X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Feb 2017 23:01:31 -0000 Author: dim Date: Thu Feb 2 23:01:29 2017 New Revision: 313110 URL: https://svnweb.freebsd.org/changeset/base/313110 Log: Pull in r293773 from upstream llvm trunk (by Sanjay Patel): [ValueTracking] avoid crashing from bad assumptions (PR31809) A program may contain llvm.assume info that disagrees with other analysis. This may be caused by UB in the program, so we must not crash because of that. As noted in the code comments: https://llvm.org/bugs/show_bug.cgi?id=31809 ...we can do better, but this at least avoids the assert/crash in the bug report. Differential Revision: https://reviews.llvm.org/D29395 This fixes an assertion when building editors/emacs-devel. PR: 216614 Modified: projects/clang400-import/contrib/llvm/lib/Analysis/ValueTracking.cpp Modified: projects/clang400-import/contrib/llvm/lib/Analysis/ValueTracking.cpp ============================================================================== --- projects/clang400-import/contrib/llvm/lib/Analysis/ValueTracking.cpp Thu Feb 2 22:02:10 2017 (r313109) +++ projects/clang400-import/contrib/llvm/lib/Analysis/ValueTracking.cpp Thu Feb 2 23:01:29 2017 (r313110) @@ -781,6 +781,23 @@ static void computeKnownBitsFromAssume(c APInt::getHighBitsSet(BitWidth, RHSKnownZero.countLeadingOnes()); } } + + // If assumptions conflict with each other or previous known bits, then we + // have a logical fallacy. This should only happen when a program has + // undefined behavior. We can't assert/crash, so clear out the known bits and + // hope for the best. + + // FIXME: Publish a warning/remark that we have encountered UB or the compiler + // is broken. + + // FIXME: Implement a stronger version of "I give up" by invalidating/clearing + // the assumption cache. This should indicate that the cache is corrupted so + // future callers will not waste time repopulating it with faulty assumptions. + + if ((KnownZero & KnownOne) != 0) { + KnownZero.clearAllBits(); + KnownOne.clearAllBits(); + } } // Compute known bits from a shift operator, including those with a