instcombine: Don't replace all uses for instructions with no uses
[oota-llvm.git] / lib / Transforms / InstCombine / InstCombineCalls.cpp
index 48f270429e5a66a25625c221deb504a9c79efbe9..b7b45a2473f430471181467f31ac3a39663a22a0 100644 (file)
@@ -786,7 +786,7 @@ Instruction *InstCombiner::tryOptimizeCall(CallInst *CI, const DataLayout *TD) {
   if (CI->getCalledFunction() == 0) return 0;
 
   if (Value *With = Simplifier->optimizeCall(CI))
-    return ReplaceInstUsesWith(*CI, With);
+    return CI->use_empty() ? CI : ReplaceInstUsesWith(*CI, With);
 
   return 0;
 }