[polly] 4c6ae8e - [polly] Fix cppcheck SA comments reported in #82263 (#85749)
via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 9 19:52:03 PDT 2024
Author: Karthika Devi C
Date: 2024-04-09T19:51:59-07:00
New Revision: 4c6ae8ebb69525118e7fc3cf57908e9de74ebef9
URL: https://github.com/llvm/llvm-project/commit/4c6ae8ebb69525118e7fc3cf57908e9de74ebef9
DIFF: https://github.com/llvm/llvm-project/commit/4c6ae8ebb69525118e7fc3cf57908e9de74ebef9.diff
LOG: [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.
Added:
Modified:
polly/lib/Support/GICHelper.cpp
polly/lib/Transform/MatmulOptimizer.cpp
Removed:
################################################################################
diff --git a/polly/lib/Support/GICHelper.cpp b/polly/lib/Support/GICHelper.cpp
index 0e491944c162e4..04d422cf994623 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 51ae5a778e4fa3..ff1683b2d63c59 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
More information about the llvm-commits
mailing list