2 ms·
It's not aiming at the function NeverCalled; it's aiming at EraseAll. As the article states, if a local static function has exactly one assignment to it, then
by pcwalton 9y ago
It's not aiming at the function NeverCalled; it's aiming at EraseAll.
As the article states, if a local static function has exactly one assignment to it, then it can be an important optimization to assume that it will always have that value. Imagine that it's some kind of "DebugPrintf(...)" function that, in release builds, is always set to a no-op that does nothing before being called. You would definitely want that indirect function call to be inlined to nothing in release.
- kazinator 9y agoFor debug functions that completely disappear in release builds, we have inline functions with conditionally empty bodies or old-school macros. It is a (decades ago) Solved Problem.