[llvm] [NFC][Coverage] Do not use recursion for GCOV propagateCounts. (PR #68455)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 9 15:58:37 PDT 2023
================
@@ -366,24 +366,80 @@ GCOVBlock &GCOVFunction::getExitBlock() const {
// outgoing edge counts by Kirchoff's circuit law. If the unmeasured arcs form a
// spanning tree, the count for each unmeasured arc (GCOV_ARC_ON_TREE) can be
// uniquely identified.
-uint64_t GCOVFunction::propagateCounts(const GCOVBlock &v, GCOVArc *pred) {
- // If GCOV_ARC_ON_TREE edges do form a tree, visited is not needed; otherwise
- // this prevents infinite recursion.
- if (!visited.insert(&v).second)
- return 0;
+uint64_t GCOVFunction::propagateCounts(const GCOVBlock &V, GCOVArc *Pred) {
+ struct StackElem {
+ const GCOVBlock &Block;
+ GCOVArc *Pred;
+ size_t PrevStackElemIdx;
----------------
shen3qing1 wrote:
The pointer to Parent is not stable because we push back/remove the vector, which invalidate all reference/pointers.
https://github.com/llvm/llvm-project/pull/68455
More information about the llvm-commits
mailing list