mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-10-18 18:42:46 +02:00
[CSSPGO][llvm-profgen] Fix an issue in findDisjointRanges
We were using 0 as an indicator of invalid offset when computing disjoint ranges. In reality, 0 can be an valid code offset which stands for the first function in .text section. I'm using UINT64_MAX as an invalid code offset instead. Reviewed By: wenlei Differential Revision: https://reviews.llvm.org/D104497
This commit is contained in:
parent
de2155141d
commit
d9e9fe620c
@ -179,19 +179,20 @@ void ProfileGenerator::findDisjointRanges(RangeSample &DisjointRanges,
|
|||||||
Boundaries[End].addEndCount(Count);
|
Boundaries[End].addEndCount(Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t BeginAddress = 0;
|
uint64_t BeginAddress = UINT64_MAX;
|
||||||
int Count = 0;
|
int Count = 0;
|
||||||
for (auto Item : Boundaries) {
|
for (auto Item : Boundaries) {
|
||||||
uint64_t Address = Item.first;
|
uint64_t Address = Item.first;
|
||||||
BoundaryPoint &Point = Item.second;
|
BoundaryPoint &Point = Item.second;
|
||||||
if (Point.BeginCount) {
|
if (Point.BeginCount) {
|
||||||
if (BeginAddress)
|
if (BeginAddress != UINT64_MAX)
|
||||||
DisjointRanges[{BeginAddress, Address - 1}] = Count;
|
DisjointRanges[{BeginAddress, Address - 1}] = Count;
|
||||||
Count += Point.BeginCount;
|
Count += Point.BeginCount;
|
||||||
BeginAddress = Address;
|
BeginAddress = Address;
|
||||||
}
|
}
|
||||||
if (Point.EndCount) {
|
if (Point.EndCount) {
|
||||||
assert(BeginAddress && "First boundary point cannot be 'end' point");
|
assert((BeginAddress != UINT64_MAX) &&
|
||||||
|
"First boundary point cannot be 'end' point");
|
||||||
DisjointRanges[{BeginAddress, Address}] = Count;
|
DisjointRanges[{BeginAddress, Address}] = Count;
|
||||||
Count -= Point.EndCount;
|
Count -= Point.EndCount;
|
||||||
BeginAddress = Address + 1;
|
BeginAddress = Address + 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user