[llvm] [ctx_prof] Fix `ProfileAnnotator::allTakenPathsExit` (PR #109183)
Teresa Johnson via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 18 13:51:59 PDT 2024
================
@@ -233,28 +233,37 @@ class ProfileAnnotator final {
std::deque<const BasicBlock *> Worklist;
DenseSet<const BasicBlock *> Visited;
Worklist.push_back(&F.getEntryBlock());
- Visited.insert(&F.getEntryBlock());
+ bool HitExit = false;
while (!Worklist.empty()) {
const auto *BB = Worklist.front();
Worklist.pop_front();
- if (succ_size(BB) <= 1)
+ if (!Visited.insert(BB).second)
continue;
+ if (succ_size(BB) == 0) {
+ if (isa<UnreachableInst>(BB->getTerminator()))
+ return false;
+ HitExit = true;
+ continue;
+ }
+ if (succ_size(BB) == 1) {
+ llvm::append_range(Worklist, successors(BB));
+ continue;
+ }
const auto &BBInfo = getBBInfo(*BB);
- bool Inserted = false;
+ bool HasAWayOut = false;
for (auto I = 0U; I < BB->getTerminator()->getNumSuccessors(); ++I) {
----------------
teresajohnson wrote:
can this use succ_size as used above, for consistency? And maybe call that once and save the result.
https://github.com/llvm/llvm-project/pull/109183
More information about the llvm-commits
mailing list