[Git][ghc/ghc][wip/mangoiv/ghc-9.12-bp] profiling: partial backport of 2dadf3b0 to fix #27121