llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-bolt Author: Amir Ayupov (aaupov) <details> <summary>Changes</summary> Don't attempt to parse mispredictions for memory entries in LBR profile. Test Plan: added merge-fdata-mem-prof.test --- Full diff: https://github.com/llvm/llvm-project/pull/128108.diff 2 Files Affected: - (added) bolt/test/merge-fdata-mem-prof.test (+13) - (modified) bolt/tools/merge-fdata/merge-fdata.cpp (+10-3) ``````````diff diff --git a/bolt/test/merge-fdata-mem-prof.test b/bolt/test/merge-fdata-mem-prof.test new file mode 100644 index 0000000000000..166d6028f7737 --- /dev/null +++ b/bolt/test/merge-fdata-mem-prof.test @@ -0,0 +1,13 @@ +## Check that merge-fdata tool correctly handles memory profile + +# REQUIRES: system-linux + +# RUN: split-file %s %t +# RUN: merge-fdata %t/a.fdata -o %t/merged.fdata +# RUN: FileCheck %s --input-file %t/merged.fdata + +# CHECK: 4 Curl_cf_def_query c 4 Curl_cft_h1_proxy 68 3 + +#--- a.fdata +4 Curl_cf_def_query c 4 Curl_cft_h1_proxy 68 1 +4 Curl_cf_def_query c 4 Curl_cft_h1_proxy 68 2 diff --git a/bolt/tools/merge-fdata/merge-fdata.cpp b/bolt/tools/merge-fdata/merge-fdata.cpp index 74a5f8ca2d477..0cf5a03501728 100644 --- a/bolt/tools/merge-fdata/merge-fdata.cpp +++ b/bolt/tools/merge-fdata/merge-fdata.cpp @@ -316,11 +316,15 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) { do { StringRef Line(FdataLine); CounterTy Count; + unsigned Type = 0; + if (Line.split(' ').first.getAsInteger(10, Type)) + report_error(Filename, "Malformed / corrupted entry type"); + bool IsBranchEntry = Type < 3; auto [Signature, ExecCount] = Line.rsplit(' '); if (ExecCount.getAsInteger(10, Count.Exec)) report_error(Filename, "Malformed / corrupted execution count"); - // Only LBR profile has misprediction field - if (!NoLBRCollection.value_or(false)) { + // Only LBR profile has misprediction field, branch entries + if (!NoLBRCollection.value_or(false) && IsBranchEntry) { auto [SignatureLBR, MispredCount] = Signature.rsplit(' '); Signature = SignatureLBR; if (MispredCount.getAsInteger(10, Count.Mispred)) @@ -356,7 +360,10 @@ void mergeLegacyProfiles(const SmallVectorImpl<std::string> &Filenames) { output() << "no_lbr\n"; for (const auto &[Key, Value] : MergedProfile) { output() << Key << " "; - if (!NoLBRCollection.value_or(false)) + unsigned Type = 0; + Key.split(' ').first.getAsInteger(10, Type); + bool IsBranchEntry = Type < 3; + if (!NoLBRCollection.value_or(false) && IsBranchEntry) output() << Value.Mispred << " "; output() << Value.Exec << "\n"; } `````````` </details> https://github.com/llvm/llvm-project/pull/128108 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits