LoopVectorize: Don't assume pointees are sized
[oota-llvm.git] / lib / Transforms / Vectorize / LoopVectorize.cpp
index f02cf0a55bdb3309da1dfe6560a8f675b64d3c34..0a472dc7d89277a779aad3ae36c493b4910a647a 100644 (file)
@@ -5265,7 +5265,13 @@ LoopVectorizationLegality::isInductionVariable(PHINode *Phi) {
     return IK_NoInduction;
 
   assert(PhiTy->isPointerTy() && "The PHI must be a pointer");
-  uint64_t Size = DL->getTypeAllocSize(PhiTy->getPointerElementType());
+  Type *PointerElementType = PhiTy->getPointerElementType();
+  // The pointer stride cannot be determined if the pointer element type is not
+  // sized.
+  if (!PointerElementType->isSized())
+    return IK_NoInduction;
+
+  uint64_t Size = DL->getTypeAllocSize(PointerElementType);
   if (C->getValue()->equalsInt(Size))
     return IK_PtrInduction;
   else if (C->getValue()->equalsInt(0 - Size))