summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/lib/Transforms/ExprTypeConvert.cpp1
-rw-r--r--llvm/lib/Transforms/TransformInternals.cpp1
2 files changed, 2 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/ExprTypeConvert.cpp b/llvm/lib/Transforms/ExprTypeConvert.cpp
index b7936377e76..e830beee44b 100644
--- a/llvm/lib/Transforms/ExprTypeConvert.cpp
+++ b/llvm/lib/Transforms/ExprTypeConvert.cpp
@@ -49,6 +49,7 @@ static bool MallocConvertibleToType(MallocInst *MI, const Type *Ty,
// Get information about the base datatype being allocated, before & after
int ReqTypeSize = TD.getTypeSize(Ty);
+ if (ReqTypeSize == 0) return false;
unsigned OldTypeSize = TD.getTypeSize(MI->getType()->getElementType());
// Must have a scale or offset to analyze it...
diff --git a/llvm/lib/Transforms/TransformInternals.cpp b/llvm/lib/Transforms/TransformInternals.cpp
index 7aa5564fbee..c8e5ecc5f2b 100644
--- a/llvm/lib/Transforms/TransformInternals.cpp
+++ b/llvm/lib/Transforms/TransformInternals.cpp
@@ -119,6 +119,7 @@ const Type *ConvertibleToGEP(const Type *Ty, Value *OffsetVal,
if (!ElTy->isSized() || (isa<PointerType>(CompTy) && !Indices.empty()))
return 0; // Type is unreasonable... escape!
unsigned ElSize = TD.getTypeSize(ElTy);
+ if (ElSize == 0) return 0; // Avoid division by zero...
int64_t ElSizeS = ElSize;
// See if the user is indexing into a different cell of this array...
OpenPOWER on IntegriCloud