summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms
diff options
context:
space:
mode:
authorJohn Criswell <criswell@uiuc.edu>2005-06-29 15:03:18 +0000
committerJohn Criswell <criswell@uiuc.edu>2005-06-29 15:03:18 +0000
commit4642afdcc139c7a0882730957ac76c62a6f6389d (patch)
treefc69bb9371dfc1fe3d2f80b36458de4147086b51 /llvm/lib/Transforms
parent4401049f05b94b7df9117e4aea895e5a3721ffa5 (diff)
downloadbcm5719-llvm-4642afdcc139c7a0882730957ac76c62a6f6389d.tar.gz
bcm5719-llvm-4642afdcc139c7a0882730957ac76c62a6f6389d.zip
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
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r--llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp b/llvm/lib/Transforms/IPO/SimplifyLibCalls.cpp
index a2ca6921476..fb4df738184 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<Value*> args;
args.push_back(ci->getOperand(2));
args.push_back(ConstantUInt::get(SLC.getIntPtrType(),len));
OpenPOWER on IntegriCloud