[llvm-dev] InlineCost.cpp -- Use addCost instead of Cost += ...?

Riyaz Puthiyapurayil via llvm-dev llvm-dev at lists.llvm.org
Thu Dec 9 18:30:04 PST 2021


Shouldn't this:

https://llvm.org/doxygen/InlineCost_8cpp_source.html

  977     // If this function uses the coldcc calling convention, prefer not to inline
  978     // it.
  979     if (F<https://llvm.org/doxygen/MD5_8cpp.html#a96d73bbd7af15cb1fc38c3f4a3bd82e9>.getCallingConv() == CallingConv::Cold<https://llvm.org/doxygen/namespacellvm_1_1CallingConv.html#ae2dfe07f8d22cb91b60f72aae89c228fa94ec9273479164e4aec1d5d91b71dc85>)
  980       Cost += InlineConstants::ColdccPenalty<https://llvm.org/doxygen/namespacellvm_1_1InlineConstants.html#a169b2b8289fb0aefc607ae29c8b95cc6>;

be changed to:

  977     // If this function uses the coldcc calling convention, prefer not to inline
  978     // it.
  979     if (F<https://llvm.org/doxygen/MD5_8cpp.html#a96d73bbd7af15cb1fc38c3f4a3bd82e9>.getCallingConv() == CallingConv::Cold<https://llvm.org/doxygen/namespacellvm_1_1CallingConv.html#ae2dfe07f8d22cb91b60f72aae89c228fa94ec9273479164e4aec1d5d91b71dc85>)
  980       addCost(InlineConstants::ColdccPenalty<https://llvm.org/doxygen/namespacellvm_1_1InlineConstants.html#a169b2b8289fb0aefc607ae29c8b95cc6>);

Maybe, it is unlikely for Cost to overflow that early in the cost computation but for consistency's sake, it should perhaps use addCost.

/Riyaz
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211210/e66028f5/attachment.html>


More information about the llvm-dev mailing list