================ @@ -208,6 +208,27 @@ bool DataflowAnalysisContext::equivalentFormulas(const Formula &Val1, return isUnsatisfiable(std::move(Constraints)); } +llvm::DenseSet<Atom> DataflowAnalysisContext::getTransitiveClosure( + const llvm::DenseSet<Atom> &Tokens) const { + llvm::DenseSet<Atom> VisitedTokens; + // Use a worklist algorithm, with `Remaining` holding the worklist. + std::vector<Atom> Remaining(Tokens.begin(), Tokens.end()); + + // For each token in `Remaining`, add its dependencies to the worklist. + while (!Remaining.empty()) { + auto Token = Remaining.back(); + Remaining.pop_back(); + if (!VisitedTokens.insert(Token).second) + continue; + if (auto DepsIt = FlowConditionDeps.find(Token); + DepsIt != FlowConditionDeps.end()) + for (Atom A : DepsIt->second) + Remaining.push_back(A); ---------------- usx95 wrote:
If we talk about the latest suggestion, I don't see how we will push `B` again. The idea is that when we push a token, we mark it as `TokensSeen` before even visiting it. And if a token was already "seen" it is never pushed again. | Current | TokensSeen | Remaining | | :---------------- | :--------: | :-------: | | initial condition | A | A | | A | ABC | BC | | B | ABC | C | | C | ABC | null | https://github.com/llvm/llvm-project/pull/152487 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits