LLZK
3.0.0
An open-source IR for Zero Knowledge (ZK) circuits
Toggle main menu visibility
Loading...
Searching...
No Matches
GraphUtil.h
Go to the documentation of this file.
1
//===-- GraphUtil.h ---------------------------------------------*- C++ -*-===//
2
//
3
// Part of the LLZK Project, under the Apache License v2.0.
4
// See LICENSE.txt for license information.
5
// Copyright 2025 Veridise Inc.
6
// SPDX-License-Identifier: Apache-2.0
7
//
8
//===----------------------------------------------------------------------===//
9
10
#pragma once
11
12
#include <llvm/ADT/GraphTraits.h>
13
#include <llvm/ADT/SCCIterator.h>
14
15
namespace
llzk
{
16
17
template
<
typename
GraphT>
inline
bool
hasCycle
(
const
GraphT &G) {
18
for
(llvm::scc_iterator<GraphT> I = llvm::scc_begin(G), E = llvm::scc_end(G); I != E; ++I) {
19
const
std::vector<typename llvm::GraphTraits<GraphT>::NodeRef> &SCC = *I;
20
if
(SCC.size() > 1) {
21
return
true
;
22
}
23
// Detect self-loop
24
auto
*N = SCC.front();
25
for
(
auto
*child : llvm::children<GraphT>(N)) {
26
if
(child == N) {
27
return
true
;
28
}
29
}
30
}
31
return
false
;
32
}
33
34
}
// namespace llzk
llzk
Definition
AnalysisPassEnums.cpp:19
llzk::hasCycle
bool hasCycle(const GraphT &G)
Definition
GraphUtil.h:17
include
llzk
Analysis
GraphUtil.h
Generated by
1.17.0
Copyright 2025 Veridise Inc. under the Apache License v2.0. Copyright 2026 Project LLZK under the Apache License v2.0.