diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp index 76904ad3f97..8fa5342ff3b 100644 --- a/lib/VMCore/Constants.cpp +++ b/lib/VMCore/Constants.cpp @@ -668,10 +668,12 @@ void ConstantPointerNull::refineAbstractType(const DerivedType *OldTy, Value::refineAbstractType(OldTy, NewTy); // Make everyone now use a constant of the new type... - replaceAllUsesWith(ConstantPointerNull::get(cast(NewTy))); - - // This constant is now dead, destroy it. - destroyConstant(); + if (NewTy != OldTy) { + replaceAllUsesWith(ConstantPointerNull::get(cast(NewTy))); + + // This constant is now dead, destroy it. + destroyConstant(); + } }