Skip to content

Commit

Permalink
Don't assert about missing profile info in createProfileWeightsForLoop
Browse files Browse the repository at this point in the history
The compiler shouldn't crash if the profile info is slightly off. We hit
this in Chromium.

Differential revision: https://reviews.llvm.org/D79417
  • Loading branch information
zmodem committed May 5, 2020
1 parent 0e6536f commit 55b9b11
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions clang/lib/CodeGen/CodeGenPGO.cpp
Expand Up @@ -1051,8 +1051,7 @@ llvm::MDNode *CodeGenFunction::createProfileWeightsForLoop(const Stmt *Cond,
if (!PGO.haveRegionCounts())
return nullptr;
Optional<uint64_t> CondCount = PGO.getStmtCount(Cond);
assert(CondCount.hasValue() && "missing expected loop condition count");
if (*CondCount == 0)
if (!CondCount || *CondCount == 0)
return nullptr;
return createProfileWeights(LoopCount,
std::max(*CondCount, LoopCount) - LoopCount);
Expand Down

0 comments on commit 55b9b11

Please sign in to comment.