diff options
author | Chris Lattner <sabre@nondot.org> | 2003-06-23 17:36:49 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-06-23 17:36:49 +0000 |
commit | bf2c46254a1dce11ee0c3c0b78d47f62b665c1d5 (patch) | |
tree | c212ae1e334d94b3418f55b0bd4ed18169065a66 /llvm/lib/Transforms | |
parent | 50b1d41ad4fc5292f20801e6b07c2a2a61bcf85e (diff) | |
download | bcm5719-llvm-bf2c46254a1dce11ee0c3c0b78d47f62b665c1d5.tar.gz bcm5719-llvm-bf2c46254a1dce11ee0c3c0b78d47f62b665c1d5.zip |
avoid dividing by zero when dealing with zero sized types (like [0 x double])
llvm-svn: 6862
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/ExprTypeConvert.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Transforms/TransformInternals.cpp | 1 |
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... |