[llvm] e6a1044 - [ModuleSummaryAnalysis] Avoid duplicate elements in Worklist. NFC
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Mar 6 14:19:28 PST 2021
Author: Fangrui Song
Date: 2021-03-06T14:19:22-08:00
New Revision: e6a104465d9b6bba3944b2b03f3825bb6bcf24f9
URL: https://github.com/llvm/llvm-project/commit/e6a104465d9b6bba3944b2b03f3825bb6bcf24f9
DIFF: https://github.com/llvm/llvm-project/commit/e6a104465d9b6bba3944b2b03f3825bb6bcf24f9.diff
LOG: [ModuleSummaryAnalysis] Avoid duplicate elements in Worklist. NFC
Added:
Modified:
llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
index c9afdadd7335..e596327cba3b 100644
--- a/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ b/llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -91,14 +91,11 @@ static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
SmallPtrSet<const User *, 8> &Visited) {
bool HasBlockAddress = false;
SmallVector<const User *, 32> Worklist;
- Worklist.push_back(CurUser);
+ if (Visited.insert(CurUser).second)
+ Worklist.push_back(CurUser);
while (!Worklist.empty()) {
const User *U = Worklist.pop_back_val();
-
- if (!Visited.insert(U).second)
- continue;
-
const auto *CB = dyn_cast<CallBase>(U);
for (const auto &OI : U->operands()) {
@@ -117,7 +114,8 @@ static bool findRefEdges(ModuleSummaryIndex &Index, const User *CurUser,
RefEdges.insert(Index.getOrInsertValueInfo(GV));
continue;
}
- Worklist.push_back(Operand);
+ if (Visited.insert(Operand).second)
+ Worklist.push_back(Operand);
}
}
return HasBlockAddress;
More information about the llvm-commits
mailing list