[llvm] [BOLT] solve the profile data processing problem when BAT and no_lbr are set at the same time (PR #86501)

via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 25 06:21:52 PDT 2024


https://github.com/zct created https://github.com/llvm/llvm-project/pull/86501

when BAT and no_lbr are set at the same time, the perf2bolt writes boltedcollection first and then no_lbr

https://github.com/llvm/llvm-project/blob/e6f63a942a45e3545332cd9a43982a69a4d5667b/bolt/lib/Profile/DataAggregator.cpp#L2219-L2225

However, when used, llvm-bolt reads the no_lbr first, and then the boltedcollection

https://github.com/llvm/llvm-project/blob/e6f63a942a45e3545332cd9a43982a69a4d5667b/bolt/lib/Profile/DataReader.cpp#L1175-L1183

This causes an error when reading profile data
```shell
BOLT-INFO: pre-processing profile using branch profile reader
ERROR: no valid profile data found
BOLT-ERROR: 'cannot pre-process profile': Input/output error.
``` 
So we adjusted the order of the reads

>From 9eded6853ad5beffc4b5afdf7a29e1d9558c9a24 Mon Sep 17 00:00:00 2001
From: zct <317712914 at qq.com>
Date: Mon, 25 Mar 2024 21:07:23 +0800
Subject: [PATCH] [BOLT] solve the profile data processing problem when BAT and
 no_lbr are set at the same time

---
 bolt/lib/Profile/DataReader.cpp | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp
index aa21eb121ad652..b535e3ab33eb40 100644
--- a/bolt/lib/Profile/DataReader.cpp
+++ b/bolt/lib/Profile/DataReader.cpp
@@ -1172,16 +1172,16 @@ std::error_code DataReader::parse() {
 
   Col = 0;
   Line = 1;
-  ErrorOr<bool> FlagOrErr = maybeParseNoLBRFlag();
-  if (!FlagOrErr)
-    return FlagOrErr.getError();
-  NoLBRMode = *FlagOrErr;
-
   ErrorOr<bool> BATFlagOrErr = maybeParseBATFlag();
   if (!BATFlagOrErr)
     return BATFlagOrErr.getError();
   BATMode = *BATFlagOrErr;
 
+  ErrorOr<bool> FlagOrErr = maybeParseNoLBRFlag();
+  if (!FlagOrErr)
+    return FlagOrErr.getError();
+  NoLBRMode = *FlagOrErr;
+
   if (!hasBranchData() && !hasMemData()) {
     Diag << "ERROR: no valid profile data found\n";
     return make_error_code(llvm::errc::io_error);



More information about the llvm-commits mailing list