ICF optimization runs multiple passes and the order in which functions
are folded could be dependent on the order they are being processed.
This order is indeterministic as functions are intermediately stored in
std::unordered_map<>. Note that this order is mostly stable, but is not
guaranteed to be and can change e.g. after switching to a different C++
library implementation.
Because the processing (and folding) order is indeterministic, the
previous way of calculating merged function call count could produce
different results.
Change the way we calculate the ICF call count to make it independent of
the function folding/processing order.
Mostly NFC as the output binary should remain the same, the change
affects only the console output.
Just curious may we just call ChildBF.setFolded(&ParentBF) here? AFAIU it is done only for non-relocation mode since there were no need to mark folded function in rel mode since we're just removing them from the map. If we would still mark function as folded here we may just check isFolded() state in ICF pass.