https://gcc.gnu.org/bugzilla/show_bug.cgi?id=120614
--- Comment #20 from Jan Hubicka <hubicka at ucw dot cz> --- > We were also looking at the profile count issues with CSE/ICF like > optimisations. > https://lists.llvm.org/pipermail/llvm-dev/2020-November/146694.html looks like > the way to go. CSE should be safe if debug statements were working, since we optimize out the code, but keep debug statement. For my testing I am currently disabling ICF. I am not quite sure what to do about ICF optimized functions. For direct calls they will show up as worng call targets with -Wauto-profile. Jakub extened dwarf to handle some replacements so correct function show up which can be useful here, but to be able to read back profile to pre-ICF code we would need to know right locations that are lost at merging time. I would first track easier issues and see how far we get. We may have -ffor-auto-profile which disables few auto-profile unfriendly optimizations for example.