Fix some logic I broke that caused a regression on
SimplifyLibCalls/2005-05-20-sprintf-crash.ll
llvm-svn: 23430
diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index a11bde1..ae76a4d 100644
--- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -1500,9 +1500,11 @@
new CallInst(memcpy_func, args, "", ci);
// The strlen result is the unincremented number of bytes in the string.
- if (!ci->use_empty() && Len->getType() != ci->getType())
- Len = new CastInst(Len, ci->getType(), Len->getName(), ci);
- ci->replaceAllUsesWith(Len);
+ if (!ci->use_empty()) {
+ if (Len->getType() != ci->getType())
+ Len = new CastInst(Len, ci->getType(), Len->getName(), ci);
+ ci->replaceAllUsesWith(Len);
+ }
ci->eraseFromParent();
return true;
}