aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Transforms/Utils/LoopUtils.cpp
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2015-06-05 10:52:40 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2015-06-05 10:52:40 +0000
commitb58f32f7a84e98b51fd87ac9b49dba02b06fa7bc (patch)
treeb6b3e7cacdb97e21f8eb1aec699a3ea881131974 /llvm/lib/Transforms/Utils/LoopUtils.cpp
parenteb33134ce791de41bc2fd2f11eb3d7732e009ce5 (diff)
downloadllvm-b58f32f7a84e98b51fd87ac9b49dba02b06fa7bc.zip
llvm-b58f32f7a84e98b51fd87ac9b49dba02b06fa7bc.tar.gz
llvm-b58f32f7a84e98b51fd87ac9b49dba02b06fa7bc.tar.bz2
[LoopVectorize] Don't crash on zero-sized types in isInductionPHI
isInductionPHI wants to calculate the stride based on the pointee size. However, this is not possible when the pointee is zero sized. This fixes PR23763. llvm-svn: 239143
Diffstat (limited to 'llvm/lib/Transforms/Utils/LoopUtils.cpp')
-rw-r--r--llvm/lib/Transforms/Utils/LoopUtils.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/LoopUtils.cpp b/llvm/lib/Transforms/Utils/LoopUtils.cpp
index a5890c0..5f25e6b 100644
--- a/llvm/lib/Transforms/Utils/LoopUtils.cpp
+++ b/llvm/lib/Transforms/Utils/LoopUtils.cpp
@@ -491,6 +491,9 @@ bool llvm::isInductionPHI(PHINode *Phi, ScalarEvolution *SE,
const DataLayout &DL = Phi->getModule()->getDataLayout();
int64_t Size = static_cast<int64_t>(DL.getTypeAllocSize(PointerElementType));
+ if (!Size)
+ return false;
+
int64_t CVSize = CV->getSExtValue();
if (CVSize % Size)
return false;