llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

polly: 3 * trivial performance issues

Open dcb314 opened this issue 2 years ago • 7 comments

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.

dcb314 avatar Feb 19 '24 16:02 dcb314

@llvm/issue-subscribers-polly

Author: None (dcb314)

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.

llvmbot avatar Feb 19 '24 17:02 llvmbot

My team will take a look into addressing these issues.

chrisj-quic avatar Feb 20 '24 17:02 chrisj-quic

The suggestion might not be correct and the actual fix might be to add a std::move() (see https://trac.cppcheck.net/ticket/12384).

firewave avatar Feb 22 '24 17:02 firewave

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 ?

dcb314 avatar Feb 22 '24 17:02 dcb314

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.

firewave avatar Feb 22 '24 20:02 firewave

?? 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.

dcb314 avatar Feb 22 '24 21:02 dcb314

Created PR to address this - https://github.com/llvm/llvm-project/pull/85749/

kartcq avatar Mar 19 '24 11:03 kartcq