summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-04-29 20:09:21 +0000
committerChris Lattner <sabre@nondot.org>2002-04-29 20:09:21 +0000
commit767210feb70705e8c8576ecdda028b976acbce18 (patch)
tree16add4c90e3141018dbfb1edea2b2984e2354322 /llvm/lib/Transforms
parent70f274b3a6a9887ef99ab0e4837984934546e939 (diff)
downloadbcm5719-llvm-767210feb70705e8c8576ecdda028b976acbce18.tar.gz
bcm5719-llvm-767210feb70705e8c8576ecdda028b976acbce18.zip
Fix for problem when allocating something like this:
malloc(100-i); llvm-svn: 2409
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/ExprTypeConvert.cpp10
1 files changed, 3 insertions, 7 deletions
diff --git a/llvm/lib/Transforms/ExprTypeConvert.cpp b/llvm/lib/Transforms/ExprTypeConvert.cpp
index 9f75198e1ca..02ee7b2d953 100644
--- a/llvm/lib/Transforms/ExprTypeConvert.cpp
+++ b/llvm/lib/Transforms/ExprTypeConvert.cpp
@@ -62,7 +62,7 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
analysis::ExprType Expr = analysis::ClassifyExpression(MI->getArraySize());
// Get information about the base datatype being allocated, before & after
- unsigned ReqTypeSize = TD.getTypeSize(Ty);
+ int ReqTypeSize = TD.getTypeSize(Ty);
unsigned OldTypeSize = TD.getTypeSize(MI->getType()->getElementType());
// Must have a scale or offset to analyze it...
@@ -71,15 +71,11 @@ static bool MallocConvertableToType(MallocInst *MI, const Type *Ty,
// Get the offset and scale of the allocation...
int OffsetVal = Expr.Offset ? getConstantValue(Expr.Offset) : 0;
int ScaleVal = Expr.Scale ? getConstantValue(Expr.Scale) : (Expr.Var ? 1 : 0);
- if (ScaleVal < 0 || OffsetVal < 0) {
- cerr << "malloc of a negative number???\n";
- return false;
- }
// The old type might not be of unit size, take old size into consideration
// here...
- unsigned Offset = (unsigned)OffsetVal * OldTypeSize;
- unsigned Scale = (unsigned)ScaleVal * OldTypeSize;
+ int Offset = OffsetVal * OldTypeSize;
+ int Scale = ScaleVal * OldTypeSize;
// In order to be successful, both the scale and the offset must be a multiple
// of the requested data type's size.
OpenPOWER on IntegriCloud