[PATCH] D93073: [llvm-cov gcov] Replace Donald B. Johnson's cycle enumeration with iterative cycle finding

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 10 19:26:51 PST 2020


MaskRay added inline comments.


================
Comment at: llvm/lib/ProfileData/GCOV.cpp:433
+  stack.emplace_back(u, 0);
+  u->incoming = (GCOVArc *)1; // Mark u available for cycle detection
+  for (;;) {
----------------
xinhaoyuan wrote:
> Is it possible to have self-arc? If so this pointer would be de-referenced below.
Neither GCC nor Clang can produce self arcs. gcov instrumentation splits critical edges. With a self arc, the from-vertex will have more than one outgoing arcs and the to-vertex will have more than one incoming arcs. Such edges must have been split.

But thanks for the reminder: we should guard against bad input. So I added a self arc check.


================
Comment at: llvm/lib/ProfileData/GCOV.cpp:467
+    }
+    return flow;
   }
----------------
xinhaoyuan wrote:
> when returned with a cycle found. "incoming" of the blocks on the cycle would not be cleared. can it lead to undefined behaviors in the subsequent traversal?
Good catch! I'll set the visited bits for these blocks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93073/new/

https://reviews.llvm.org/D93073



More information about the llvm-commits mailing list