From 4642afdcc139c7a0882730957ac76c62a6f6389d Mon Sep 17 00:00:00 2001 From: John Criswell Date: Wed, 29 Jun 2005 15:03:18 +0000 Subject: [PATCH] Basic fix for PR#591; don't convert an fprintf() to an fwrite() if there is a mismatch in their character type pointers (i.e. fprintf() prints an array of ubytes while fwrite() takes an array of sbytes). We can probably do better than this (such as casting the ubyte to an sbyte). llvm-svn: 22310 --- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp index a2ca69214763..fb4df738184d 100644 --- a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp +++ b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp @@ -1305,6 +1305,15 @@ public: Function* fwrite_func = SLC.get_fwrite(FILEptr_type); if (!fwrite_func) return false; + + // Make sure that the fprintf() and fwrite() functions both take the + // same type of char pointer. + if (ci->getOperand(2)->getType() != + fwrite_func->getFunctionType()->getParamType(0)) + { + return false; + } + std::vector args; args.push_back(ci->getOperand(2)); args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));