Apply Aton's LLVM patch for PR973: Linux ctors / dtors support.
[oota-llvm.git] / lib / Support / ConstantRange.cpp
index 109ed42cfc2c9b58471bc8190bc3a094cf9a2544..9e12c9343db4521b2e61e28f660eebf904a7b200 100644 (file)
@@ -30,8 +30,8 @@
 using namespace llvm;
 
 static ConstantIntegral *Next(ConstantIntegral *CI) {
-  if (CI->getType() == Type::BoolTy)
-    return CI == ConstantBool::True ? ConstantBool::False : ConstantBool::True;
+  if (ConstantBool *CB = dyn_cast<ConstantBool>(CI))
+    return ConstantBool::get(!CB->getValue());
 
   Constant *Result = ConstantExpr::getAdd(CI,
                                           ConstantInt::get(CI->getType(), 1));
@@ -161,7 +161,7 @@ uint64_t ConstantRange::getSetSize() const {
 
   // Simply subtract the bounds...
   Constant *Result = ConstantExpr::getSub(Upper, Lower);
-  return cast<ConstantInt>(Result)->getRawValue();
+  return cast<ConstantInt>(Result)->getZExtValue();
 }
 
 /// contains - Return true if the specified value is in the set.
@@ -288,7 +288,7 @@ ConstantRange ConstantRange::zeroExtend(const Type *Ty) const {
     // Change a source full set into [0, 1 << 8*numbytes)
     unsigned SrcTySize = getLower()->getType()->getPrimitiveSize();
     return ConstantRange(Constant::getNullValue(Ty),
-                         ConstantUInt::get(Ty, 1ULL << SrcTySize*8));
+                         ConstantInt::get(Ty, 1ULL << SrcTySize*8));
   }
 
   Constant *Lower = getLower();