[llvm-commits] CVS: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp

John Criswell criswell at cs.uiuc.edu
Wed Jun 29 08:03:35 PDT 2005



Changes in directory llvm/lib/Transforms/IPO:

SimplifyLibCalls.cpp updated: 1.43 -> 1.44
---
Log message:

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).


---
Diffs of the changes:  (+9 -0)

 SimplifyLibCalls.cpp |    9 +++++++++
 1 files changed, 9 insertions(+)


Index: llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
diff -u llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.43 llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.44
--- llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp:1.43	Sat Jun 18 12:46:28 2005
+++ llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp	Wed Jun 29 10:03:18 2005
@@ -1305,6 +1305,15 @@
       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<Value*> args;
       args.push_back(ci->getOperand(2));
       args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));






More information about the llvm-commits mailing list