[PATCH] D109637: [llvm-profgen] Ignore broken LBR samples
Hongtao Yu via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 13 14:13:39 PDT 2021
hoy updated this revision to Diff 372341.
hoy added a comment.
Addressing Lei's comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D109637/new/
https://reviews.llvm.org/D109637
Files:
llvm/tools/llvm-profgen/PerfReader.cpp
llvm/tools/llvm-profgen/PerfReader.h
llvm/tools/llvm-profgen/ProfileGenerator.cpp
Index: llvm/tools/llvm-profgen/ProfileGenerator.cpp
===================================================================
--- llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -183,6 +183,7 @@
for (auto Item : Ranges) {
uint64_t Begin = Item.first.first;
uint64_t End = Item.first.second;
+ assert(Begin <= End && "invalid instruction range");
uint64_t Count = Item.second;
if (Boundaries.find(Begin) == Boundaries.end())
Boundaries[Begin] = BoundaryPoint();
@@ -194,7 +195,7 @@
}
uint64_t BeginAddress = UINT64_MAX;
- int Count = 0;
+ uint64_t Count = 0;
for (auto Item : Boundaries) {
uint64_t Address = Item.first;
BoundaryPoint &Point = Item.second;
@@ -208,6 +209,7 @@
assert((BeginAddress != UINT64_MAX) &&
"First boundary point cannot be 'end' point");
DisjointRanges[{BeginAddress, Address}] = Count;
+ assert(Count >= Point.EndCount && "mismatched live ranges");
Count -= Point.EndCount;
BeginAddress = Address + 1;
}
Index: llvm/tools/llvm-profgen/PerfReader.h
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.h
+++ llvm/tools/llvm-profgen/PerfReader.h
@@ -373,6 +373,7 @@
BranchSample BranchCounter;
void recordRangeCount(uint64_t Start, uint64_t End, uint64_t Repeat) {
+ assert(Start <= End && "Invalid instruction range");
RangeCounter[{Start, End}] += Repeat;
}
void recordBranchCount(uint64_t Source, uint64_t Target, uint64_t Repeat) {
Index: llvm/tools/llvm-profgen/PerfReader.cpp
===================================================================
--- llvm/tools/llvm-profgen/PerfReader.cpp
+++ llvm/tools/llvm-profgen/PerfReader.cpp
@@ -422,8 +422,11 @@
Token.split(Addresses, "/");
uint64_t Src;
uint64_t Dst;
- Addresses[0].substr(2).getAsInteger(16, Src);
- Addresses[1].substr(2).getAsInteger(16, Dst);
+
+ // Stop at broken LBR records.
+ if (Addresses[0].substr(2).getAsInteger(16, Src) ||
+ Addresses[1].substr(2).getAsInteger(16, Dst))
+ break;
bool SrcIsInternal = Binary->addressIsCode(Src);
bool DstIsInternal = Binary->addressIsCode(Dst);
@@ -635,11 +638,8 @@
// If this not the first LBR, update the range count between TO of current
// LBR and FROM of next LBR.
uint64_t StartOffset = TargetOffset;
- if (EndOffeset != 0) {
- assert(StartOffset <= EndOffeset &&
- "Bogus range should be filtered ealier!");
+ if (EndOffeset != 0)
Counter.recordRangeCount(StartOffset, EndOffeset, Repeat);
- }
EndOffeset = SourceOffset;
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109637.372341.patch
Type: text/x-patch
Size: 2699 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210913/6a246347/attachment.bin>
More information about the llvm-commits
mailing list