[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.
This commit is contained in:
Karthika Devi C 2024-04-10 08:21:59 +05:30 committed by GitHub
parent 349327f7e7
commit 4c6ae8ebb6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 12 deletions

View File

@ -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();
}
}

View File

@ -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