[InstCombine] Fix the signature of fgets_unlocked.
It returns a pointer, not an int. This miscompiles all code that uses
the return value of fgets.
llvm-svn: 332531
diff --git a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
index bf912b0..5f5c415 100644
--- a/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
+++ b/llvm/lib/Transforms/Utils/BuildLibCalls.cpp
@@ -1166,8 +1166,8 @@
Module *M = B.GetInsertBlock()->getModule();
Constant *F =
- M->getOrInsertFunction("fgets_unlocked", B.getInt32Ty(), B.getInt8PtrTy(),
- B.getInt32Ty(), File->getType());
+ M->getOrInsertFunction("fgets_unlocked", B.getInt8PtrTy(),
+ B.getInt8PtrTy(), B.getInt32Ty(), File->getType());
inferLibFuncAttributes(*M->getFunction("fgets_unlocked"), *TLI);
CallInst *CI =
B.CreateCall(F, {castToCStr(Str, B), Size, File}, "fgets_unlocked");