[llvm] fb19aa0 - [CSSPGO][llvm-profgen] Fix an issue in findDisjointRanges
Hongtao Yu via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 14:39:01 PDT 2021
Author: Hongtao Yu
Date: 2021-06-18T14:38:48-07:00
New Revision: fb19aa0c74fdb864ddbd677a7b3585661966a098
URL: https://github.com/llvm/llvm-project/commit/fb19aa0c74fdb864ddbd677a7b3585661966a098
DIFF: https://github.com/llvm/llvm-project/commit/fb19aa0c74fdb864ddbd677a7b3585661966a098.diff
LOG: [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
Added:
Modified:
llvm/tools/llvm-profgen/ProfileGenerator.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-profgen/ProfileGenerator.cpp b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
index 5c96ca938e61..e0a31937dcbe 100644
--- a/llvm/tools/llvm-profgen/ProfileGenerator.cpp
+++ b/llvm/tools/llvm-profgen/ProfileGenerator.cpp
@@ -179,19 +179,20 @@ void ProfileGenerator::findDisjointRanges(RangeSample &DisjointRanges,
Boundaries[End].addEndCount(Count);
}
- uint64_t BeginAddress = 0;
+ uint64_t BeginAddress = UINT64_MAX;
int Count = 0;
for (auto Item : Boundaries) {
uint64_t Address = Item.first;
BoundaryPoint &Point = Item.second;
if (Point.BeginCount) {
- if (BeginAddress)
+ if (BeginAddress != UINT64_MAX)
DisjointRanges[{BeginAddress, Address - 1}] = Count;
Count += Point.BeginCount;
BeginAddress = Address;
}
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;
Count -= Point.EndCount;
BeginAddress = Address + 1;
More information about the llvm-commits
mailing list