diff options
author | Karthika Devi C <quic_kartc@quicinc.com> | 2024-04-10 08:21:59 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-09 19:51:59 -0700 |
commit | 4c6ae8ebb69525118e7fc3cf57908e9de74ebef9 (patch) | |
tree | 652b5e605635e29eeaedc84f358756618457fb46 | |
parent | 349327f7e73ab7a314ef08c463dd04fcea623150 (diff) | |
download | llvm-4c6ae8ebb69525118e7fc3cf57908e9de74ebef9.zip llvm-4c6ae8ebb69525118e7fc3cf57908e9de74ebef9.tar.gz llvm-4c6ae8ebb69525118e7fc3cf57908e9de74ebef9.tar.bz2 |
[polly] Fix cppcheck SA comments reported in #82263 (#85749)
This patch addresses the (performance )suggestions by checkcpp static
analyzer for couple of files. Here we use const reference for the
suggested function arguments.
Fixes #82263.
-rw-r--r-- | polly/lib/Support/GICHelper.cpp | 15 | ||||
-rw-r--r-- | polly/lib/Transform/MatmulOptimizer.cpp | 8 |
2 files changed, 11 insertions, 12 deletions
diff --git a/polly/lib/Support/GICHelper.cpp b/polly/lib/Support/GICHelper.cpp index 0e49194..04d422c 100644 --- a/polly/lib/Support/GICHelper.cpp +++ b/polly/lib/Support/GICHelper.cpp @@ -83,10 +83,10 @@ APInt polly::APIntFromVal(__isl_take isl_val *Val) { } template <typename ISLTy, typename ISL_CTX_GETTER, typename ISL_PRINTER> -static inline std::string stringFromIslObjInternal(__isl_keep ISLTy *isl_obj, - ISL_CTX_GETTER ctx_getter_fn, - ISL_PRINTER printer_fn, - std::string DefaultValue) { +static inline std::string +stringFromIslObjInternal(__isl_keep ISLTy *isl_obj, + ISL_CTX_GETTER ctx_getter_fn, ISL_PRINTER printer_fn, + const std::string &DefaultValue) { if (!isl_obj) return DefaultValue; isl_ctx *ctx = ctx_getter_fn(isl_obj); @@ -134,12 +134,11 @@ ISL_C_OBJECT_TO_STRING(union_map) ISL_C_OBJECT_TO_STRING(union_pw_aff) ISL_C_OBJECT_TO_STRING(union_pw_multi_aff) -static void replace(std::string &str, const std::string &find, - const std::string &replace) { +static void replace(std::string &str, StringRef find, StringRef replace) { size_t pos = 0; while ((pos = str.find(find, pos)) != std::string::npos) { - str.replace(pos, find.length(), replace); - pos += replace.length(); + str.replace(pos, find.size(), replace); + pos += replace.size(); } } diff --git a/polly/lib/Transform/MatmulOptimizer.cpp b/polly/lib/Transform/MatmulOptimizer.cpp index 51ae5a7..ff1683b2 100644 --- a/polly/lib/Transform/MatmulOptimizer.cpp +++ b/polly/lib/Transform/MatmulOptimizer.cpp @@ -598,7 +598,7 @@ createMacroKernel(isl::schedule_node Node, /// @param MMI Parameters of the matrix multiplication operands. /// @return The size of the widest type of the matrix multiplication operands /// in bytes, including alignment padding. -static uint64_t getMatMulAlignTypeSize(MatMulInfoTy MMI) { +static uint64_t getMatMulAlignTypeSize(const MatMulInfoTy &MMI) { auto *S = MMI.A->getStatement()->getParent(); auto &DL = S->getFunction().getParent()->getDataLayout(); auto ElementSizeA = DL.getTypeAllocSize(MMI.A->getElementType()); @@ -613,7 +613,7 @@ static uint64_t getMatMulAlignTypeSize(MatMulInfoTy MMI) { /// @param MMI Parameters of the matrix multiplication operands. /// @return The size of the widest type of the matrix multiplication operands /// in bits. -static uint64_t getMatMulTypeSize(MatMulInfoTy MMI) { +static uint64_t getMatMulTypeSize(const MatMulInfoTy &MMI) { auto *S = MMI.A->getStatement()->getParent(); auto &DL = S->getFunction().getParent()->getDataLayout(); auto ElementSizeA = DL.getTypeSizeInBits(MMI.A->getElementType()); @@ -635,7 +635,7 @@ static uint64_t getMatMulTypeSize(MatMulInfoTy MMI) { /// @return The structure of type MicroKernelParamsTy. /// @see MicroKernelParamsTy static MicroKernelParamsTy getMicroKernelParams(const TargetTransformInfo *TTI, - MatMulInfoTy MMI) { + const MatMulInfoTy &MMI) { assert(TTI && "The target transform info should be provided."); // Nvec - Number of double-precision floating-point numbers that can be hold @@ -712,7 +712,7 @@ static void getTargetCacheParameters(const llvm::TargetTransformInfo *TTI) { static MacroKernelParamsTy getMacroKernelParams(const llvm::TargetTransformInfo *TTI, const MicroKernelParamsTy &MicroKernelParams, - MatMulInfoTy MMI) { + const MatMulInfoTy &MMI) { getTargetCacheParameters(TTI); // According to www.cs.utexas.edu/users/flame/pubs/TOMS-BLIS-Analytical.pdf, // it requires information about the first two levels of a cache to determine |