From 414ad5d4a4c856fe92dfa18cc041f17d6810fe5e Mon Sep 17 00:00:00 2001 From: Dale Johannesen Date: Wed, 24 Oct 2007 20:14:50 +0000 Subject: [PATCH] Fix off by 1 bug in printf->puts lowering. llvm-svn: 43309 --- lib/Transforms/IPO/SimplifyLibCalls.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Transforms/IPO/SimplifyLibCalls.cpp b/lib/Transforms/IPO/SimplifyLibCalls.cpp index 717a5a847f8..0904c4c6c19 100644 --- a/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1211,8 +1211,10 @@ public: 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)); }