[PATCH] D74691: [Attributor] Detect possibly unbounded cycles in functions
Stefanos Baziotis via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 25 11:24:34 PST 2020
baziotis added a comment.
In D74691#1891862 <https://reviews.llvm.org/D74691#1891862>, @omarahmed wrote:
> bool containsCycle(BasicBlock *BB, SmallPtrSet<BasicBlock *, 32> &Visited, SmallPtrSet<BasicBlock *, 32> &Processed) {
> if (Processed.count(BB)) {
> Visited.erase(BB);
> return false;
> }
> Processed.insert(BB);
> Visited.insert(BB);
> for (auto *SuccBB : successors(BB)) {
> if (!Processed.count(SuccBB) && containsCycle(SuccBB, Visited, Processed))
> return true;
> else if (Visited.count(SuccBB))
> return true;
> }
> Visited.erase(BB);
> return false;
> }
>
>
> what i get is that we will implement dfs by our hand
Yes
> to detect SCCs
Cycles, it's a little bit different.
> so can't we use stack method in dfs that will provide us to not split the function into 2 and keep all the logic inside contains cycle
Yes you can. But note that the runtime stack (which is implemented in the hardware) is quite faster than a software stack.
OTOH, a software stack is not as limited to its depth as a software stack. But, given that we pass a single pointer, it should
be able to handle quite a big number of blocks.
It's an implementation detail and not the most important thing. That would be the algorithm. I'd prefer the recursion but we can sure ask @jdoerfert on this.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D74691/new/
https://reviews.llvm.org/D74691
More information about the llvm-commits
mailing list