diff options
author | dim <dim@FreeBSD.org> | 2014-12-09 07:48:25 +0000 |
---|---|---|
committer | dim <dim@FreeBSD.org> | 2014-12-09 07:48:25 +0000 |
commit | f9b5954255fa3dca6de150affb48d8729fbb1c22 (patch) | |
tree | 6dbe335b4a077a2b8f4c64e07a8def9a2e3e6a2a /contrib/llvm/lib/Transforms/Vectorize | |
parent | 9f5c1c161118f96daf3e00a5ac4e71e4ec08ef35 (diff) | |
download | FreeBSD-src-f9b5954255fa3dca6de150affb48d8729fbb1c22.zip FreeBSD-src-f9b5954255fa3dca6de150affb48d8729fbb1c22.tar.gz |
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.
Diffstat (limited to 'contrib/llvm/lib/Transforms/Vectorize')
-rw-r--r-- | contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 531d349..c1e8df9 100644 --- a/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/contrib/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -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'); |