aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms/Scalar/SimplifyLibCalls.cpp
diff options
context:
space:
mode:
authorMeador Inge <meadori@codesourcery.com>2012-11-29 15:45:43 +0000
committerMeador Inge <meadori@codesourcery.com>2012-11-29 15:45:43 +0000
commit5c5e230ac7ab03937f685baaf78525fd2b8154f1 (patch)
tree0a219068c175a9d1de0f53c2bdfe3c7351c048bd /lib/Transforms/Scalar/SimplifyLibCalls.cpp
parentc2e331275bac0e5e16f24bdb3ae4bc39a3caba5b (diff)
instcombine: Migrate fputs optimizations
This patch migrates the fputs optimizations from the simplify-libcalls pass into the instcombine library call simplifier. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168893 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/SimplifyLibCalls.cpp')
-rw-r--r--lib/Transforms/Scalar/SimplifyLibCalls.cpp27
1 files changed, 0 insertions, 27 deletions
diff --git a/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
index 7e44b03942..7a224122d4 100644
--- a/lib/Transforms/Scalar/SimplifyLibCalls.cpp
+++ b/lib/Transforms/Scalar/SimplifyLibCalls.cpp
@@ -87,31 +87,6 @@ namespace {
//===----------------------------------------------------------------------===//
//===---------------------------------------===//
-// 'fputs' Optimizations
-
-struct FPutsOpt : public LibCallOptimization {
- virtual Value *CallOptimizer(Function *Callee, CallInst *CI, IRBuilder<> &B) {
- // These optimizations require DataLayout.
- if (!TD) return 0;
-
- // Require two pointers. Also, we can't optimize if return value is used.
- FunctionType *FT = Callee->getFunctionType();
- if (FT->getNumParams() != 2 || !FT->getParamType(0)->isPointerTy() ||
- !FT->getParamType(1)->isPointerTy() ||
- !CI->use_empty())
- return 0;
-
- // fputs(s,F) --> fwrite(s,1,strlen(s),F)
- uint64_t Len = GetStringLength(CI->getArgOperand(0));
- if (!Len) return 0;
- // Known to have no uses (see above).
- return EmitFWrite(CI->getArgOperand(0),
- ConstantInt::get(TD->getIntPtrType(*Context), Len-1),
- CI->getArgOperand(1), B, TD, TLI);
- }
-};
-
-//===---------------------------------------===//
// 'puts' Optimizations
struct PutsOpt : public LibCallOptimization {
@@ -153,7 +128,6 @@ namespace {
StringMap<LibCallOptimization*> Optimizations;
// Formatting and IO Optimizations
- FPutsOpt FPuts;
PutsOpt Puts;
bool Modified; // This is only used by doInitialization.
@@ -210,7 +184,6 @@ void SimplifyLibCalls::AddOpt(LibFunc::Func F1, LibFunc::Func F2,
/// we know.
void SimplifyLibCalls::InitOptimizations() {
// Formatting and IO Optimizations
- AddOpt(LibFunc::fputs, &FPuts);
Optimizations["puts"] = &Puts;
}