[PATCH] D149597: [FS-AFDO] Do not load non-FS profile in MIR loader.
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 10 16:39:47 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG958a3d8e2dec: [FS-AFDO] Do not load non-FS profile in MIR loader. (authored by hoy).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D149597/new/
https://reviews.llvm.org/D149597
Files:
llvm/include/llvm/ProfileData/SampleProfReader.h
llvm/lib/CodeGen/MIRSampleProfile.cpp
llvm/test/CodeGen/X86/fsafdo_test2.ll
Index: llvm/test/CodeGen/X86/fsafdo_test2.ll
===================================================================
--- llvm/test/CodeGen/X86/fsafdo_test2.ll
+++ llvm/test/CodeGen/X86/fsafdo_test2.ll
@@ -5,7 +5,8 @@
; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true < %s | FileCheck %s --check-prefixes=V1,V01
; RUN: llvm-profdata merge --sample -profile-isfs -o %t1.afdo %S/Inputs/fsloader_v1.afdo
; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%t1.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=LOADERV1,LOADER
-;
+; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%S/Inputs/fsloader_v1.afdo -profile-isfs -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=LOADERV1,LOADER
+; RUN: llc -enable-fs-discriminator -improved-fs-discriminator=true -fs-profile-file=%S/Inputs/fsloader_v1.afdo -show-fs-branchprob -disable-ra-fsprofile-loader=false -disable-layout-fsprofile-loader=false < %s 2>&1 | FileCheck %s --check-prefixes=NOLOAD
;;
;; C source code for the test (compiler at -O3):
;; // A test case for loop unroll.
@@ -82,6 +83,9 @@
; LOADER: Set branch fs prob: MBB (16 -> 18): unroll.c:24:11-->unroll.c:19:3 W=283590 0x30000000 / 0x80000000 = 37.50% --> 0x16588166 / 0x80000000 = 17.46%
; LOADER: Set branch fs prob: MBB (16 -> 17): unroll.c:24:11 W=283590 0x50000000 / 0x80000000 = 62.50% --> 0x69a77e9a / 0x80000000 = 82.54%
+;; Check that the profile is not loaded since the reader doesn't know it is a FS profile.
+; NOLOAD-NOT: Set branch fs prob
+
target triple = "x86_64-unknown-linux-gnu"
@sum = dso_local local_unnamed_addr global i32 0, align 4
Index: llvm/lib/CodeGen/MIRSampleProfile.cpp
===================================================================
--- llvm/lib/CodeGen/MIRSampleProfile.cpp
+++ llvm/lib/CodeGen/MIRSampleProfile.cpp
@@ -308,6 +308,15 @@
}
bool MIRProfileLoader::runOnFunction(MachineFunction &MF) {
+ // Do not load non-FS profiles. A line or probe can get a zero-valued
+ // discriminator at certain pass which could result in accidentally loading
+ // the corresponding base counter in the non-FS profile, while a non-zero
+ // discriminator would end up getting zero samples. This could in turn undo
+ // the sample distribution effort done by previous BFI maintenance and the
+ // probe distribution factor work for pseudo probes.
+ if (!Reader->profileIsFS())
+ return false;
+
Function &Func = MF.getFunction();
clearFunctionData(false);
Samples = Reader->getSamplesFor(Func);
Index: llvm/include/llvm/ProfileData/SampleProfReader.h
===================================================================
--- llvm/include/llvm/ProfileData/SampleProfReader.h
+++ llvm/include/llvm/ProfileData/SampleProfReader.h
@@ -483,6 +483,9 @@
/// Whether input profile contains ShouldBeInlined contexts.
bool profileIsPreInlined() const { return ProfileIsPreInlined; }
+ /// Whether input profile is flow-sensitive.
+ bool profileIsFS() const { return ProfileIsFS; }
+
virtual std::unique_ptr<ProfileSymbolList> getProfileSymbolList() {
return nullptr;
};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149597.521155.patch
Type: text/x-patch
Size: 3314 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230510/eea3f7af/attachment.bin>
More information about the llvm-commits
mailing list