Skip to content

Commit 80393ba

Browse files
authored
[llvm-profgen] Fix assertion condition for the top-level probes address range checks (llvm#198674)
Top-level functions may contains multiple disjoint address ranges, and the pseudo probes may not be stored as sorted. The original assertion check is problematic because the first pseudo probe may not necessarily falls into the current function range even though they are both part of the same function. Update the assertion condition so that we won't hit the assertion failure as long as there one pseudo probe falls in the checked function range.
1 parent 57b485f commit 80393ba

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

llvm/tools/llvm-profgen/ProfiledBinary.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1243,10 +1243,11 @@ void ProfiledBinary::loadSymbolsFromPseudoProbe() {
12431243
InlineTreeNode->Parent);
12441244

12451245
auto TopLevelProbes = InlineTreeNode->getProbes();
1246-
[[maybe_unused]] auto TopProbe = TopLevelProbes.begin();
1247-
assert(TopProbe != TopLevelProbes.end() &&
1248-
TopProbe->getAddress() >= StartAddr &&
1249-
TopProbe->getAddress() < EndAddr &&
1246+
assert(llvm::any_of(TopLevelProbes,
1247+
[Start = StartAddr, End = EndAddr](const auto &P) {
1248+
return P.getAddress() >= Start &&
1249+
P.getAddress() < End;
1250+
}) &&
12501251
"Top level pseudo probe does not match function range");
12511252

12521253
const auto *ProbeDesc = getFuncDescForGUID(InlineTreeNode->Guid);

0 commit comments

Comments
 (0)