https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119719
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- So this sounds like what autofdo does. I suspect you could hook up a similar method for any profiling like program to autofdo. Currently the autofdo uses perf (the Linux kernel userland tool) output to do it. but it is just a bunch of scripts which creates the autofdo output to the PC.