[llvm] r283005 - Use StringRef in TLI instead of raw pointer (NFC)
Mehdi Amini via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 30 20:10:48 PDT 2016
Author: mehdi_amini
Date: Fri Sep 30 22:10:48 2016
New Revision: 283005
URL: http://llvm.org/viewvc/llvm-project?rev=283005&view=rev
Log:
Use StringRef in TLI instead of raw pointer (NFC)
Modified:
llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h
llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
Modified: llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h?rev=283005&r1=283004&r2=283005&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h (original)
+++ llvm/trunk/include/llvm/Analysis/TargetLibraryInfo.h Fri Sep 30 22:10:48 2016
@@ -25,8 +25,8 @@ template <typename T> class ArrayRef;
/// Function 'VectorFnName' is equivalent to 'ScalarFnName' vectorized
/// by a factor 'VectorizationFactor'.
struct VecDesc {
- const char *ScalarFnName;
- const char *VectorFnName;
+ StringRef ScalarFnName;
+ StringRef VectorFnName;
unsigned VectorizationFactor;
};
@@ -50,7 +50,7 @@ class TargetLibraryInfoImpl {
unsigned char AvailableArray[(LibFunc::NumLibFuncs+3)/4];
llvm::DenseMap<unsigned, std::string> CustomNames;
- static const char *const StandardNames[LibFunc::NumLibFuncs];
+ static StringRef const StandardNames[LibFunc::NumLibFuncs];
enum AvailabilityState {
StandardName = 3, // (memset to all ones)
Modified: llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp?rev=283005&r1=283004&r2=283005&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp (original)
+++ llvm/trunk/lib/Analysis/TargetLibraryInfo.cpp Fri Sep 30 22:10:48 2016
@@ -27,7 +27,7 @@ static cl::opt<TargetLibraryInfoImpl::Ve
"Intel SVML library"),
clEnumValEnd));
-const char *const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
+StringRef const TargetLibraryInfoImpl::StandardNames[LibFunc::NumLibFuncs] = {
#define TLI_DEFINE_STRING
#include "llvm/Analysis/TargetLibraryInfo.def"
};
@@ -54,11 +54,11 @@ static bool hasSinCosPiStret(const Tripl
/// specified target triple. This should be carefully written so that a missing
/// target triple gets a sane set of defaults.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T,
- ArrayRef<const char *> StandardNames) {
+ ArrayRef<StringRef> StandardNames) {
// Verify that the StandardNames array is in alphabetical order.
assert(std::is_sorted(StandardNames.begin(), StandardNames.end(),
- [](const char *LHS, const char *RHS) {
- return strcmp(LHS, RHS) < 0;
+ [](StringRef LHS, StringRef RHS) {
+ return LHS < RHS;
}) &&
"TargetLibraryInfoImpl function names must be sorted");
@@ -472,16 +472,16 @@ static StringRef sanitizeFunctionName(St
bool TargetLibraryInfoImpl::getLibFunc(StringRef funcName,
LibFunc::Func &F) const {
- const char *const *Start = &StandardNames[0];
- const char *const *End = &StandardNames[LibFunc::NumLibFuncs];
+ StringRef const *Start = &StandardNames[0];
+ StringRef const *End = &StandardNames[LibFunc::NumLibFuncs];
funcName = sanitizeFunctionName(funcName);
if (funcName.empty())
return false;
- const char *const *I = std::lower_bound(
- Start, End, funcName, [](const char *LHS, StringRef RHS) {
- return std::strncmp(LHS, RHS.data(), RHS.size()) < 0;
+ StringRef const *I = std::lower_bound(
+ Start, End, funcName, [](StringRef LHS, StringRef RHS) {
+ return LHS < RHS;
});
if (I != End && *I == funcName) {
F = (LibFunc::Func)(I - Start);
@@ -1011,21 +1011,19 @@ void TargetLibraryInfoImpl::disableAllFu
}
static bool compareByScalarFnName(const VecDesc &LHS, const VecDesc &RHS) {
- return std::strncmp(LHS.ScalarFnName, RHS.ScalarFnName,
- std::strlen(RHS.ScalarFnName)) < 0;
+ return LHS.ScalarFnName < RHS.ScalarFnName;
}
static bool compareByVectorFnName(const VecDesc &LHS, const VecDesc &RHS) {
- return std::strncmp(LHS.VectorFnName, RHS.VectorFnName,
- std::strlen(RHS.VectorFnName)) < 0;
+ return LHS.VectorFnName < RHS.VectorFnName;
}
static bool compareWithScalarFnName(const VecDesc &LHS, StringRef S) {
- return std::strncmp(LHS.ScalarFnName, S.data(), S.size()) < 0;
+ return LHS.ScalarFnName < S;
}
static bool compareWithVectorFnName(const VecDesc &LHS, StringRef S) {
- return std::strncmp(LHS.VectorFnName, S.data(), S.size()) < 0;
+ return LHS.VectorFnName < S;
}
void TargetLibraryInfoImpl::addVectorizableFunctions(ArrayRef<VecDesc> Fns) {
More information about the llvm-commits
mailing list