diff options
| author | Meador Inge <meadori@codesourcery.com> | 2012-11-29 15:45:43 +0000 | 
|---|---|---|
| committer | Meador Inge <meadori@codesourcery.com> | 2012-11-29 15:45:43 +0000 | 
| commit | f8e725081c399679e928ad3cf9e7a1314f023240 (patch) | |
| tree | 9694b8219c7fd589453623d424cae755b7a71a4b /llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp | |
| parent | bc84d1a4f56ccbe55c37d43e7d7a6814ef238e62 (diff) | |
| download | bcm5719-llvm-f8e725081c399679e928ad3cf9e7a1314f023240.tar.gz bcm5719-llvm-f8e725081c399679e928ad3cf9e7a1314f023240.zip  | |
instcombine: Migrate fputs optimizations
This patch migrates the fputs optimizations from the simplify-libcalls
pass into the instcombine library call simplifier.
llvm-svn: 168893
Diffstat (limited to 'llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp | 27 | 
1 files changed, 0 insertions, 27 deletions
diff --git a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp b/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp index 7e44b03942c..7a224122d4b 100644 --- a/llvm/lib/Transforms/Scalar/SimplifyLibCalls.cpp +++ b/llvm/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;  }  | 

