Skip to content

[PartialInlining] Use DenseSet instead of DenseMap (NFC) #127170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions llvm/lib/Transforms/IPO/PartialInlining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -412,9 +412,9 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo(
bool ColdCandidateFound = false;
BasicBlock *CurrEntry = EntryBlock;
std::vector<BasicBlock *> DFS;
DenseMap<BasicBlock *, bool> VisitedMap;
SmallPtrSet<BasicBlock *, 8> VisitedSet;
DFS.push_back(CurrEntry);
VisitedMap[CurrEntry] = true;
VisitedSet.insert(CurrEntry);

// Use Depth First Search on the basic blocks to find CFG edges that are
// considered cold.
Expand All @@ -432,9 +432,8 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo(
BBProfileCount(ThisBB) < MinBlockCounterExecution)
continue;
for (auto SI = succ_begin(ThisBB); SI != succ_end(ThisBB); ++SI) {
if (VisitedMap[*SI])
if (!VisitedSet.insert(*SI).second)
continue;
VisitedMap[*SI] = true;
DFS.push_back(*SI);
// If branch isn't cold, we skip to the next one.
BranchProbability SuccProb = BPI.getEdgeProbability(ThisBB, *SI);
Expand Down Expand Up @@ -492,7 +491,7 @@ PartialInlinerImpl::computeOutliningColdRegionsInfo(
// at inner regions because the outer region may have live-exit
// variables.
for (auto *BB : DominateVector)
VisitedMap[BB] = true;
VisitedSet.insert(BB);

// ReturnBlock here means the block after the outline call
BasicBlock *ReturnBlock = ExitBlock->getSingleSuccessor();
Expand Down