From owner-svn-src-projects@FreeBSD.ORG Tue Dec 9 20:05:06 2014 Return-Path: Delivered-To: svn-src-projects@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 24A6A6E1; Tue, 9 Dec 2014 20:05:06 +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 11023CC5; Tue, 9 Dec 2014 20:05:06 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sB9K55Bh066879; Tue, 9 Dec 2014 20:05:05 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sB9K55D4066878; Tue, 9 Dec 2014 20:05:05 GMT (envelope-from dim@FreeBSD.org) Message-Id: <201412092005.sB9K55D4066878@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 20:05:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r275652 - projects/clang350-import/contrib/llvm/patches 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.18-1 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: Tue, 09 Dec 2014 20:05:06 -0000 Author: dim Date: Tue Dec 9 20:05:05 2014 New Revision: 275652 URL: https://svnweb.freebsd.org/changeset/base/275652 Log: Add llvm patch corresponding to r275635. Added: projects/clang350-import/contrib/llvm/patches/patch-21-llvm-r223171-fix-vectorizer.diff Added: projects/clang350-import/contrib/llvm/patches/patch-21-llvm-r223171-fix-vectorizer.diff ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ projects/clang350-import/contrib/llvm/patches/patch-21-llvm-r223171-fix-vectorizer.diff Tue Dec 9 20:05:05 2014 (r275652) @@ -0,0 +1,75 @@ +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 + +Note: because this is applied on top of llvm/clang 3.5.0, this fix is +slightly different from the one just checked into head in r275633. + +Introduced here: http://svnweb.freebsd.org/changeset/base/275635 + +Index: lib/Transforms/Vectorize/LoopVectorize.cpp +=================================================================== +--- lib/Transforms/Vectorize/LoopVectorize.cpp (revision 21) ++++ lib/Transforms/Vectorize/LoopVectorize.cpp (revision 22) +@@ -3466,6 +3466,15 @@ bool LoopVectorizationLegality::canVectorize() { + 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()) { ++ emitAnalysis( ++ Report() << "loop control flow is not understood by vectorizer"); ++ return false; ++ } ++ + // We need to have a loop header. + DEBUG(dbgs() << "LV: Found a loop: " << + TheLoop->getHeader()->getName() << '\n'); +Index: test/Transforms/LoopVectorize/loop-form.ll +=================================================================== +--- test/Transforms/LoopVectorize/loop-form.ll (revision 0) ++++ test/Transforms/LoopVectorize/loop-form.ll (revision 22) +@@ -0,0 +1,31 @@ ++; RUN: opt -S -loop-vectorize < %s | FileCheck %s ++target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" ++ ++; Check that we vectorize only bottom-tested loops. ++; This is a reduced testcase from PR21302. ++; ++; rdar://problem/18886083 ++ ++%struct.X = type { i32, i16 } ++; CHECK-LABEL: @foo( ++; CHECK-NOT: vector.body ++ ++define void @foo(i32 %n) { ++entry: ++ br label %for.cond ++ ++for.cond: ++ %i = phi i32 [ 0, %entry ], [ %inc, %for.body ] ++ %cmp = icmp slt i32 %i, %n ++ br i1 %cmp, label %for.body, label %if.end ++ ++for.body: ++ %iprom = sext i32 %i to i64 ++ %b = getelementptr inbounds %struct.X* undef, i64 %iprom, i32 1 ++ store i16 0, i16* %b, align 4 ++ %inc = add nsw i32 %i, 1 ++ br label %for.cond ++ ++if.end: ++ ret void ++}