From owner-svn-src-head@FreeBSD.ORG Tue Dec 9 07:34:30 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 1BDF429A; Tue, 9 Dec 2014 07:34:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 E25759E4; Tue, 9 Dec 2014 07:34:29 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sB97YTSs080622; Tue, 9 Dec 2014 07:34:29 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sB97YT2X080620; Tue, 9 Dec 2014 07:34:29 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201412090734.sB97YT2X080620@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Tue, 9 Dec 2014 07:34:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r275633 - in head: contrib/llvm/lib/Transforms/Vectorize sys/sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 Dec 2014 07:34:30 -0000 Author: dim Date: Tue Dec 9 07:34:28 2014 New Revision: 275633 URL: https://svnweb.freebsd.org/changeset/base/275633 Log: Pull in r223171 from upstream llvm trunk (by Michael Zolotukhin): PR21302. Vectorize only bottom-tested loops. rdar://problem/18886083 This fixes a bug in the llvm vectorizer, which could sometimes cause vectorized loops to perform an additional iteration, leading to possible buffer overruns. Symptoms of this, which are usually segfaults, were first noticed when building gcc ports, here: https://lists.freebsd.org/pipermail/freebsd-ports/2014-September/095466.html https://lists.freebsd.org/pipermail/freebsd-toolchain/2014-September/001211.html Since this fix is very important for ports, bump __FreeBSD_version to make it easier for port maintainers to test whether the fix has been applied. Upstream PR: http://llvm.org/PR21302 MFC after: 3 days Modified: head/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp head/sys/sys/param.h Modified: head/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp ============================================================================== --- head/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Dec 9 07:19:24 2014 (r275632) +++ head/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp Tue Dec 9 07:34:28 2014 (r275633) @@ -2864,6 +2864,14 @@ bool LoopVectorizationLegality::canVecto if (!TheLoop->getExitingBlock()) return false; + // We only handle bottom-tested loops, i.e. loop in which the condition is + // checked at the end of each iteration. With that we can assume that all + // instructions in the loop are executed the same number of times. + if (TheLoop->getExitingBlock() != TheLoop->getLoopLatch()) { + DEBUG(dbgs() << "LV: loop control flow is not understood by vectorizer\n"); + return false; + } + // We need to have a loop header. DEBUG(dbgs() << "LV: Found a loop: " << TheLoop->getHeader()->getName() << '\n'); Modified: head/sys/sys/param.h ============================================================================== --- head/sys/sys/param.h Tue Dec 9 07:19:24 2014 (r275632) +++ head/sys/sys/param.h Tue Dec 9 07:34:28 2014 (r275633) @@ -58,7 +58,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1100048 /* Master, propagated to newvers */ +#define __FreeBSD_version 1100049 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,