[llvm] [llvm-profgen] Trim tail CR+LF for LBR record line (PR #93210)

via llvm-commits llvm-commits at lists.llvm.org
Thu May 23 09:04:10 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-pgo

Author: Haohai Wen (HaohaiWen)

<details>
<summary>Changes</summary>

On Windows, perfscript generated by sep contains CR+LF at the end of
LBR records line. This '\r' will be treated as an LBR record and then
generate warning.

---
Full diff: https://github.com/llvm/llvm-project/pull/93210.diff


1 Files Affected:

- (modified) llvm/tools/llvm-profgen/PerfReader.cpp (+1-1) 


``````````diff
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index e9442027aed3f..e63c6d61b3bfc 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -552,7 +552,7 @@ bool PerfScriptReader::extractLBRStack(TraceStream &TraceIt,
   //                           ... 0x4005c8/0x4005dc/P/-/-/0
   // It's in FIFO order and seperated by whitespace.
   SmallVector<StringRef, 32> Records;
-  TraceIt.getCurrentLine().split(Records, " ", -1, false);
+  TraceIt.getCurrentLine().rtrim().split(Records, " ", -1, false);
   auto WarnInvalidLBR = [](TraceStream &TraceIt) {
     WithColor::warning() << "Invalid address in LBR record at line "
                          << TraceIt.getLineNumber() << ": "

``````````

</details>


https://github.com/llvm/llvm-project/pull/93210


More information about the llvm-commits mailing list