Skip to content

[polly] Fix cppcheck SA comments reported in #82263 #85749

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions polly/lib/Support/GICHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
}
}

Expand Down
8 changes: 4 additions & 4 deletions polly/lib/Transform/MatmulOptimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,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());
Expand All @@ -612,7 +612,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());
Expand All @@ -634,7 +634,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
Expand Down Expand Up @@ -711,7 +711,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
Expand Down