[ModuleSummaryAnalysis] Avoid duplicate elements in Worklist. NFC

This commit is contained in:
Fangrui Song 2021-03-06 14:19:22 -08:00
parent fb2cf0dd60
commit e6a104465d
1 changed files with 4 additions and 6 deletions

View File

@ -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;