avoid dividing by zero when dealing with zero sized types (like [0 x double])

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6862 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2003-06-23 17:36:49 +00:00
parent 80544444a3
commit 8a334a4035
2 changed files with 2 additions and 0 deletions

View File

@ -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...

View File

@ -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...