[clang] [clang] Avoid evaluating the BitWidth expression over and over again (PR #66203)

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Fri Oct 6 05:39:32 PDT 2023


AaronBallman wrote:

> @cor3ntin Looking at this again... while I'd also like to see the general solution, I'd probably apply this anyway since it makes it clearer that this function can actually be fast. Its name is terrible for what it does. It sounds like it's a simply getter but in reality it might be pretty costly to call. This patch would mitigate this somewhat and make the performance expectations clearer when reading the code of this function.

Once we have the general solution, this code would be redundant, wouldn't it? (I also would prefer the more general solution if reasonable -- playing whack-a-mole on constant evaluation is going to make for maintenance problems and this is an issue that plagues other parts of the compiler as well.)

https://github.com/llvm/llvm-project/pull/66203


More information about the cfe-commits mailing list