[FS-AFDO] Do not load non-FS profile in MIR loader.
authorHongtao Yu <hoy@fb.com>
Wed, 10 May 2023 23:10:39 +0000 (16:10 -0700)
committerHongtao Yu <hoy@fb.com>
Wed, 10 May 2023 23:38:49 +0000 (16:38 -0700)
commit958a3d8e2dec95a878dfc9d823861b3a6c674534
treede3bb33eeef7bd83f9c1c9d12ef73eaa73907f48
parentbcc2021efdab6148fed03899648731e1cda8cfa8
[FS-AFDO] Do not load non-FS profile in MIR loader.

I was seeing a regression when enabling FS discriminators on an non-FS CSSPGO build. This is because a probe can get a zero-valued discriminator at a specific pass and that could lead to accidentally loading the corresponding base counter in the non-FS profile, while a non-zeo discriminator would end up getting zero samples. This could in turn undo the sample distribution effort done by previous BFI maintenance work and the probe distribution factor work for pseudo probes specifically. To mitigate that I'm disabling loading a non-FS profile against FS discriminators. The problem should also exist with non-CS AutoFDO, so I'm doing this for it too.

Reviewed By: wenlei

Differential Revision: https://reviews.llvm.org/D149597
llvm/include/llvm/ProfileData/SampleProfReader.h
llvm/lib/CodeGen/MIRSampleProfile.cpp
llvm/test/CodeGen/X86/fsafdo_test2.ll