[llvm] a7cdcf2 - [llvm-profgen] Ignore invalid perf line in LBR record
via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 24 13:45:31 PDT 2021
Author: wlei
Date: 2021-09-24T13:44:57-07:00
New Revision: a7cdcf25c17e169eedba276791299c3b2b78fbf1
URL: https://github.com/llvm/llvm-project/commit/a7cdcf25c17e169eedba276791299c3b2b78fbf1
DIFF: https://github.com/llvm/llvm-project/commit/a7cdcf25c17e169eedba276791299c3b2b78fbf1.diff
LOG: [llvm-profgen] Ignore invalid perf line in LBR record
Similar to https://reviews.llvm.org/D109637, there is a whole invalid line of message in perfscript.
```
warning: Invalid address in LBR record at line 14118674: Processed 14138923 events and lost 1 chunks!
warning: Invalid address in LBR record at line 14118676: Check IO/CPU overload!
```
This only happened for LBR only perfscript, hybridperfscript have a check of " 0x" to make sure it's the LBR perf line.
Reviewed By: hoy, wenlei
Differential Revision: https://reviews.llvm.org/D110424
Added:
Modified:
llvm/test/tools/llvm-profgen/Inputs/noprobe.perfscript
llvm/tools/llvm-profgen/PerfReader.cpp
Removed:
################################################################################
diff --git a/llvm/test/tools/llvm-profgen/Inputs/noprobe.perfscript b/llvm/test/tools/llvm-profgen/Inputs/noprobe.perfscript
index 19bd4a1ee34dc..da9b55514fb55 100644
--- a/llvm/test/tools/llvm-profgen/Inputs/noprobe.perfscript
+++ b/llvm/test/tools/llvm-profgen/Inputs/noprobe.perfscript
@@ -1,3 +1,4 @@
+// Invalid perf line
40062f 0x40062f/0x4005b0/P/-/-/9 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/6 0x40062f/0x4005b0/P/-/-/16 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/6 0x40062f/0x4005b0/P/-/-/6 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005c8/0x4005dc/P/-/-/8 0x40062f/0x4005b0/P/-/-/9 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/10 0x40062f/0x4005b0/P/-/-/14 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/7 0x40062f/0x4005b0/P/-/-/8 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005c8/0x4005dc/P/-/-/7 0x40062f/0x4005b0/P/-/-/15 0x400645/0x4005ff/P/-/-/1
4005d7 0x4005d7/0x4005e5/P/-/-/8 0x40062f/0x4005b0/P/-/-/6 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/2 0x4005c8/0x4005dc/P/-/-/7 0x40062f/0x4005b0/P/-/-/11 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/8 0x40062f/0x4005b0/P/-/-/9 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/5 0x40062f/0x4005b0/P/-/-/11 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/2 0x4005c8/0x4005dc/P/-/-/7 0x40062f/0x4005b0/P/-/-/10 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/8 0x40062f/0x4005b0/P/-/-/9 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/13 0x40062f/0x4005b0/P/-/-/9
4005c8 0x4005c8/0x4005dc/P/-/-/11 0x40062f/0x4005b0/P/-/-/8 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/5 0x40062f/0x4005b0/P/-/-/6 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/12 0x40062f/0x4005b0/P/-/-/6 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/2 0x4005c8/0x4005dc/P/-/-/7 0x40062f/0x4005b0/P/-/-/10 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/8 0x40062f/0x4005b0/P/-/-/9 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/1 0x4005d7/0x4005e5/P/-/-/12 0x40062f/0x4005b0/P/-/-/6 0x400645/0x4005ff/P/-/-/1 0x400637/0x400645/P/-/-/1 0x4005e9/0x400634/P/-/-/2 0x4005c8/0x4005dc/P/-/-/8 0x40062f/0x4005b0/P/-/-/8
diff --git a/llvm/tools/llvm-profgen/PerfReader.cpp b/llvm/tools/llvm-profgen/PerfReader.cpp
index 75d93f6f260b3..eaf8f12e1d563 100644
--- a/llvm/tools/llvm-profgen/PerfReader.cpp
+++ b/llvm/tools/llvm-profgen/PerfReader.cpp
@@ -417,10 +417,21 @@ bool PerfReaderBase::extractLBRStack(TraceStream &TraceIt,
// It's in FIFO order and seperated by whitespace.
SmallVector<StringRef, 32> Records;
TraceIt.getCurrentLine().split(Records, " ", -1, false);
+ auto WarnInvalidLBR = [](TraceStream &TraceIt) {
+ WithColor::warning() << "Invalid address in LBR record at line "
+ << TraceIt.getLineNumber() << ": "
+ << TraceIt.getCurrentLine() << "\n";
+ };
// Skip the leading instruction pointer.
size_t Index = 0;
+ uint64_t LeadingAddr;
if (!Records.empty() && Records[0].find('/') == StringRef::npos) {
+ if (Records[0].getAsInteger(16, LeadingAddr)) {
+ WarnInvalidLBR(TraceIt);
+ TraceIt.advance();
+ return false;
+ }
Index = 1;
}
// Now extract LBR samples - note that we do not reverse the
@@ -439,11 +450,9 @@ bool PerfReaderBase::extractLBRStack(TraceStream &TraceIt,
uint64_t Dst;
// Stop at broken LBR records.
- if (Addresses[0].substr(2).getAsInteger(16, Src) ||
+ if (Addresses.size() < 2 || Addresses[0].substr(2).getAsInteger(16, Src) ||
Addresses[1].substr(2).getAsInteger(16, Dst)) {
- WithColor::warning() << "Invalid address in LBR record at line "
- << TraceIt.getLineNumber() << ": "
- << TraceIt.getCurrentLine() << "\n";
+ WarnInvalidLBR(TraceIt);
break;
}
More information about the llvm-commits
mailing list