diff options
author | Meador Inge <meadori@codesourcery.com> | 2012-11-10 03:11:10 +0000 |
---|---|---|
committer | Meador Inge <meadori@codesourcery.com> | 2012-11-10 03:11:10 +0000 |
commit | e29c88064fb11d630d00356ad8d340b9dca9ef77 (patch) | |
tree | 2ea54b602a2b2195ca84261ebea251c02d6026cd /lib/Transforms/Utils | |
parent | 939f5002027e3ccb710ac1c3050dc25471251565 (diff) | |
download | external_llvm-e29c88064fb11d630d00356ad8d340b9dca9ef77.zip external_llvm-e29c88064fb11d630d00356ad8d340b9dca9ef77.tar.gz external_llvm-e29c88064fb11d630d00356ad8d340b9dca9ef77.tar.bz2 |
instcombine: Query target library information to gate libcall simplifications
Several of the simplifiers migrated from the simplify-libcalls pass to
the instcombine pass were not correctly checking the target library
information to gate the simplifications. This patch ensures that the
check is made.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167660 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Utils')
-rw-r--r-- | lib/Transforms/Utils/SimplifyLibCalls.cpp | 44 |
1 files changed, 25 insertions, 19 deletions
diff --git a/lib/Transforms/Utils/SimplifyLibCalls.cpp b/lib/Transforms/Utils/SimplifyLibCalls.cpp index 64c7011..f0d5491 100644 --- a/lib/Transforms/Utils/SimplifyLibCalls.cpp +++ b/lib/Transforms/Utils/SimplifyLibCalls.cpp @@ -834,6 +834,7 @@ class LibCallSimplifierImpl { StrSpnOpt StrSpn; void initOptimizations(); + void addOpt(LibFunc::Func F, LibCallOptimization* Opt); public: LibCallSimplifierImpl(const DataLayout *TD, const TargetLibraryInfo *TLI) { this->TD = TD; @@ -854,25 +855,25 @@ void LibCallSimplifierImpl::initOptimizations() { Optimizations["__stpncpy_chk"] = &StrNCpyChk; // String and memory library call optimizations. - Optimizations["strcat"] = &StrCat; - Optimizations["strncat"] = &StrNCat; - Optimizations["strchr"] = &StrChr; - Optimizations["strrchr"] = &StrRChr; - Optimizations["strcmp"] = &StrCmp; - Optimizations["strncmp"] = &StrNCmp; - Optimizations["strcpy"] = &StrCpy; - Optimizations["stpcpy"] = &StpCpy; - Optimizations["strncpy"] = &StrNCpy; - Optimizations["strlen"] = &StrLen; - Optimizations["strpbrk"] = &StrPBrk; - Optimizations["strtol"] = &StrTo; - Optimizations["strtod"] = &StrTo; - Optimizations["strtof"] = &StrTo; - Optimizations["strtoul"] = &StrTo; - Optimizations["strtoll"] = &StrTo; - Optimizations["strtold"] = &StrTo; - Optimizations["strtoull"] = &StrTo; - Optimizations["strspn"] = &StrSpn; + addOpt(LibFunc::strcat, &StrCat); + addOpt(LibFunc::strncat, &StrNCat); + addOpt(LibFunc::strchr, &StrChr); + addOpt(LibFunc::strrchr, &StrRChr); + addOpt(LibFunc::strcmp, &StrCmp); + addOpt(LibFunc::strncmp, &StrNCmp); + addOpt(LibFunc::strcpy, &StrCpy); + addOpt(LibFunc::stpcpy, &StpCpy); + addOpt(LibFunc::strncpy, &StrNCpy); + addOpt(LibFunc::strlen, &StrLen); + addOpt(LibFunc::strpbrk, &StrPBrk); + addOpt(LibFunc::strtol, &StrTo); + addOpt(LibFunc::strtod, &StrTo); + addOpt(LibFunc::strtof, &StrTo); + addOpt(LibFunc::strtoul, &StrTo); + addOpt(LibFunc::strtoll, &StrTo); + addOpt(LibFunc::strtold, &StrTo); + addOpt(LibFunc::strtoull, &StrTo); + addOpt(LibFunc::strspn, &StrSpn); } Value *LibCallSimplifierImpl::optimizeCall(CallInst *CI) { @@ -888,6 +889,11 @@ Value *LibCallSimplifierImpl::optimizeCall(CallInst *CI) { return 0; } +void LibCallSimplifierImpl::addOpt(LibFunc::Func F, LibCallOptimization* Opt) { + if (TLI->has(F)) + Optimizations[TLI->getName(F)] = Opt; +} + LibCallSimplifier::LibCallSimplifier(const DataLayout *TD, const TargetLibraryInfo *TLI) { Impl = new LibCallSimplifierImpl(TD, TLI); |