[PATCH] D31085: [InlineCost] Increase the cost of Switch
Hans Wennborg via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 25 11:00:57 PDT 2017
hans added inline comments.
================
Comment at: lib/Analysis/InlineCost.cpp:1057
+ uint64_t SwitchCost = ExpectedNumberOfCompare * 2 * InlineConstants::InstrCost;
+ Cost += std::min((uint64_t)INT_MAX, SwitchCost + (uint64_t) Cost);
+ return false;
----------------
hans wrote:
> Aren't you adding `Cost` twice here? You're doing `Cost +=` and also `SwitchCost + Cost`.
>
> Oh, Cost is just a regular int; yeah then I see how it can overflow. But std::min is returnning an uint64_t here, so it seems you're still not handling the overflow?
Oh never mind, you're capping the uint64_t at INT_MAX so it shuold work. Probably still don't want to do `Cost +=` though.
https://reviews.llvm.org/D31085
More information about the llvm-commits
mailing list