summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2014-12-13 12:14:26 +0000
committerdim <dim@FreeBSD.org>2014-12-13 12:14:26 +0000
commit3156db9097eabc078be1c06088d994af5df0b52d (patch)
treea1ef4f975b82430cb58942c10fc0c804c65e18c2
parent8b3b3c8447148612e541ae4184534ac77184e978 (diff)
downloadFreeBSD-src-3156db9097eabc078be1c06088d994af5df0b52d.zip
FreeBSD-src-3156db9097eabc078be1c06088d994af5df0b52d.tar.gz
MFC r275633:
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
-rw-r--r--contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp8
-rw-r--r--sys/sys/param.h2
2 files changed, 9 insertions, 1 deletions
diff --git a/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index f9f6b18..6a9b9dc 100644
--- a/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2864,6 +2864,14 @@ bool LoopVectorizationLegality::canVectorize() {
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');
diff --git a/sys/sys/param.h b/sys/sys/param.h
index cc20497..033c4acc 100644
--- a/sys/sys/param.h
+++ b/sys/sys/param.h
@@ -58,7 +58,7 @@
* in the range 5 to 9.
*/
#undef __FreeBSD_version
-#define __FreeBSD_version 1001503 /* Master, propagated to newvers */
+#define __FreeBSD_version 1001504 /* Master, propagated to newvers */
/*
* __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD,
OpenPOWER on IntegriCloud