Fix off by 1 bug in printf->puts lowering.
llvm-svn: 43309
diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index 717a5a8..0904c4c6 100644
--- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
+++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
@@ -1211,8 +1211,10 @@
new CallInst(SLC.get_puts(), GV, "", CI);
if (CI->use_empty()) return ReplaceCallWith(CI, 0);
+ // The return value from printf includes the \n we just removed, so +1.
return ReplaceCallWith(CI,
- ConstantInt::get(CI->getType(), FormatStr.size()));
+ ConstantInt::get(CI->getType(),
+ FormatStr.size()+1));
}