polly: 3 * trivial performance issues
Static analyser cppcheck says:
polly/lib/Support/GICHelper.cpp:89:64: performance: Function parameter 'DefaultValue' should be passed by const reference. [passedByValue] polly/lib/Transform/MatmulOptimizer.cpp:637:62: performance: Function parameter 'MMI' should be passed by const reference. [passedByValue] polly/lib/Transform/MatmulOptimizer.cpp:714:35: performance: Function parameter 'MMI' should be passed by const reference. [passedByValue]
This issue would be suitable for a new starter.
@llvm/issue-subscribers-polly
Author: None (dcb314)
polly/lib/Support/GICHelper.cpp:89:64: performance: Function parameter 'DefaultValue' should be passed by const reference. [passedByValue] polly/lib/Transform/MatmulOptimizer.cpp:637:62: performance: Function parameter 'MMI' should be passed by const reference. [passedByValue] polly/lib/Transform/MatmulOptimizer.cpp:714:35: performance: Function parameter 'MMI' should be passed by const reference. [passedByValue]
This issue would be suitable for a new starter.
My team will take a look into addressing these issues.
The suggestion might not be correct and the actual fix might be to add a std::move() (see https://trac.cppcheck.net/ticket/12384).
Avoiding string copies on stack by using const references has been a standard technique for over 35 years in C++.
Are you saying that has now changed ?
C++11 introduced std::move() which can completely enable copies in some cases. Just check the linked ticket for an example where the suggestion is misleading.
?? I don't see any mention of std::move in the example you suggest.
In general, a const reference will always be cheaper than a copy. I don't see anything here or in your example that changes that.
Created PR to address this - https://github.com/llvm/llvm-project/pull/85749/