From 5c5e230ac7ab03937f685baaf78525fd2b8154f1 Mon Sep 17 00:00:00 2001 From: Meador Inge Date: Thu, 29 Nov 2012 15:45:43 +0000 Subject: 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 --- lib/Transforms/Scalar/SimplifyLibCalls.cpp | 27 --------------------------- 1 file changed, 27 deletions(-) (limited to 'lib/Transforms/Scalar/SimplifyLibCalls.cpp') 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 @@ -86,31 +86,6 @@ namespace { // Formatting and IO Optimizations //===----------------------------------------------------------------------===// -//===---------------------------------------===// -// '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 @@ -153,7 +128,6 @@ namespace { StringMap 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; } -- cgit v1.2.3