Fix an issue where coroutine function and its await suspend wrappers are all canonicalized to the same name. This creates duplicate entries in `MD5FuncMap` (a sorted vector) and may return an incorrect GUID that mismatches the one from prof metadata and miss ICP. For example, coro function `foo` and its wrappers `foo.__await_suspend_wrapper__init`, `foo.__await_suspend_wrapper__final` are all canonicalized to `foo`. During GUID lookup, any of them can be returned due to unstable sort. This is more of the reliability issue (the indeterminism) than a performance issue because hot indirect calls should've been promoted in sample loader pass. This also fixes the same naming issue in `CGProfile` where symtab is created. By the time the pass is run, wrapper functions should already be inlined but naming collision can happen to the coro function and its post-split clones (`foo.resume`, `foo.cleanup`). This change * Unifies `InstrProfSymtab::getCanonicalName` with `FunctionSamples::getCanonicalFnName` by providing a customized list of suffixes to remove instead of removing everything after the first dot (.) except ".__uniq.". This also addresses the "FIXME" comment. * Uses stable sort when storing `MD5FuncMap` which avoids indeterminism during GUID lookup. `MD5FuncMap` can still contain duplicate entries even with this change, because no check is done before insertion. Making entries unique needs some additional work. * Checks for same PGO names before calling the second `addFuncWithName`, which does nothing in case of name match.
63 KiB
63 KiB