Use V for values, not D.
[oota-llvm.git] / lib / Transforms / ExprTypeConvert.cpp
index b7936377e7672d75cf8a8871d9641b2a07d3ec38..ac5af10a3b595237034c57c4578908e5b0f41ca3 100644 (file)
@@ -13,7 +13,7 @@
 #include "llvm/ConstantHandling.h"
 #include "llvm/Analysis/Expressions.h"
 #include "Support/STLExtras.h"
-#include "Support/Statistic.h"
+#include "Support/Debug.h"
 #include <algorithm>
 using std::cerr;
 
@@ -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...
@@ -142,13 +143,13 @@ bool ExpressionConvertibleToType(Value *V, const Type *Ty,
   ValueTypeCache::iterator CTMI = CTMap.find(V);
   if (CTMI != CTMap.end()) return CTMI->second == Ty;
 
-  // If it's a constant... all constants can be converted to a different type. We
-  // just ask the constant propagator to see if it can convert the value...
+  // If it's a constant... all constants can be converted to a different
+  // type. We just ask the constant propagator to see if it can convert the
+  // value...
   //
   if (Constant *CPV = dyn_cast<Constant>(V))
     return ConstantFoldCastInstruction(CPV, Ty);
   
-
   CTMap[V] = Ty;
   if (V->getType() == Ty) return true;  // Expression already correct type!
 
@@ -709,7 +710,7 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
       if (CTMI != CTMap.end()) {   // Operand #1 is in the table already?
         // If so, check to see if it's Ty*, or, more importantly, if it is a
         // pointer to a structure where the first element is a Ty... this code
-        // is neccesary because we might be trying to change the source and
+        // is necessary because we might be trying to change the source and
         // destination type of the store (they might be related) and the dest
         // pointer type might be a pointer to structure.  Below we allow pointer
         // to structures where the 0th element is compatible with the value,
@@ -863,7 +864,7 @@ static bool OperandConvertibleToType(User *U, Value *V, const Type *Ty,
 
       // Okay, at this point, we know that all of the arguments can be
       // converted.  We succeed if we can change the return type if
-      // neccesary...
+      // necessary...
       //
       return ValueConvertibleToType(I, FTy->getReturnType(), CTMap, TD);
     }