|
|
|
|
|
by twoodfin
971 days ago
|
|
If you are relying on profile-directed optimization, the hints are almost surely redundant. These are useful when there’s static knowledge about control flow that could assist the optimizer, e.g. with inlining decisions. For example: It’s not uncommon to have “bi-modal” functions, where simple checks guard simple actions, followed by much more complex logic to handle everything else. Are those checks for exceptional cases like an invariant violation? Think of an I/O write function confirming the device is open. Or are they the “fast path” for the most common invocations? Think of std::vector::push_back() checking for available capacity. The answer helps the optimizer immensely in deciding whether to “partially inline” the simple code into callers or not. |
|