diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 7051814a7c0..20f99134892 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -350,9 +350,6 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) { // TODO: Figure out how to test if a double can be cast to a float! case Type::FloatTyID: - /* - return (Val <= UINT8_MAX); - */ case Type::DoubleTyID: return true; // This is the largest type... } @@ -361,7 +358,8 @@ bool ConstantFP::isValueValidForType(const Type *Ty, double Val) { //===----------------------------------------------------------------------===// // replaceUsesOfWithOnConstant implementations -void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To) { +void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); std::vector Values; @@ -376,13 +374,17 @@ void ConstantArray::replaceUsesOfWithOnConstant(Value *From, Value *To) { assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... - replaceAllUsesWith(Replacement); + if (DisableChecking) + uncheckedReplaceAllUsesWith(Replacement); + else + replaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); } -void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To) { +void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking) { assert(isa(To) && "Cannot make Constant refer to non-constant!"); std::vector Values; @@ -397,33 +399,42 @@ void ConstantStruct::replaceUsesOfWithOnConstant(Value *From, Value *To) { assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... - replaceAllUsesWith(Replacement); + if (DisableChecking) + uncheckedReplaceAllUsesWith(Replacement); + else + replaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant(); } -void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To) { +void ConstantPointerRef::replaceUsesOfWithOnConstant(Value *From, Value *To, + bool DisableChecking) { if (isa(To)) { assert(From == getOperand(0) && "Doesn't contain from!"); ConstantPointerRef *Replacement = ConstantPointerRef::get(cast(To)); // Everyone using this now uses the replacement... - replaceAllUsesWith(Replacement); + if (DisableChecking) + uncheckedReplaceAllUsesWith(Replacement); + else + replaceAllUsesWith(Replacement); - // Delete the old constant! - destroyConstant(); } else { // Just replace ourselves with the To value specified. - replaceAllUsesWith(To); - - // Delete the old constant! - destroyConstant(); + if (DisableChecking) + uncheckedReplaceAllUsesWith(To); + else + replaceAllUsesWith(To); } + + // Delete the old constant! + destroyConstant(); } -void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV) { +void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV, + bool DisableChecking) { assert(isa(ToV) && "Cannot make Constant refer to non-constant!"); Constant *To = cast(ToV); @@ -457,7 +468,10 @@ void ConstantExpr::replaceUsesOfWithOnConstant(Value *From, Value *ToV) { assert(Replacement != this && "I didn't contain From!"); // Everyone using this now uses the replacement... - replaceAllUsesWith(Replacement); + if (DisableChecking) + uncheckedReplaceAllUsesWith(Replacement); + else + replaceAllUsesWith(Replacement); // Delete the old constant! destroyConstant();