-#ifndef NDEBUG
- unsigned NumUses = Uses.size();
-#endif
- Use->replaceUsesOfWith(this, D);
-
-#ifndef NDEBUG // only in -g mode...
- if (Uses.size() == NumUses) {
- std::cerr << "Use: ";
- Use->dump();
- std::cerr << "replace with: ";
- D->dump();
+ // Must handle Constants specially, we cannot call replaceUsesOfWith on a
+ // constant!
+ if (Constant *C = dyn_cast<Constant>(Use)) {
+ C->replaceUsesOfWithOnConstant(this, New);
+ } else {
+ Use->replaceUsesOfWith(this, New);