Skip to content

Commit e9e717f

Browse files
[Utils] Avoid repeated hash lookups (NFC) (#126856)
1 parent 99816a5 commit e9e717f

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

llvm/include/llvm/Transforms/Utils/SampleProfileLoaderBaseImpl.h

+6-4
Original file line numberDiff line numberDiff line change
@@ -881,19 +881,21 @@ void SampleProfileLoaderBaseImpl<BT>::buildEdges(FunctionT &F) {
881881

882882
// Add predecessors for B1.
883883
SmallPtrSet<BasicBlockT *, 16> Visited;
884-
if (!Predecessors[B1].empty())
884+
auto &Preds = Predecessors[B1];
885+
if (!Preds.empty())
885886
llvm_unreachable("Found a stale predecessors list in a basic block.");
886887
for (auto *B2 : getPredecessors(B1))
887888
if (Visited.insert(B2).second)
888-
Predecessors[B1].push_back(B2);
889+
Preds.push_back(B2);
889890

890891
// Add successors for B1.
891892
Visited.clear();
892-
if (!Successors[B1].empty())
893+
auto &Succs = Successors[B1];
894+
if (!Succs.empty())
893895
llvm_unreachable("Found a stale successors list in a basic block.");
894896
for (auto *B2 : getSuccessors(B1))
895897
if (Visited.insert(B2).second)
896-
Successors[B1].push_back(B2);
898+
Succs.push_back(B2);
897899
}
898900
}
899901

0 commit comments

Comments
 (0)