Jimborean Alexandra
2011-Mar-30 17:14 UTC
[LLVMdev] how to detect if block N is reachable from block M ?
Hi, Is there any method to check if there is a path in the CFG from block M to block N, but M does not necessarily dominate block N? In other words, if N is reachable from M. Thanks, Alexandra -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110330/7d533e42/attachment.html>
Eli Friedman
2011-Mar-31 04:35 UTC
[LLVMdev] how to detect if block N is reachable from block M ?
On Wed, Mar 30, 2011 at 10:14 AM, Jimborean Alexandra <xinfinity_a at yahoo.com> wrote:> Hi, > > Is there any method to check if there is a path in the CFG from block M to > block N, but M does not necessarily dominate block N? > In other words, if N is reachable from M.I don't think there's any method built in to LLVM. It's pretty easy to write, though. -Eli
Kenneth Uildriks
2011-Mar-31 13:12 UTC
[LLVMdev] how to detect if block N is reachable from block M ?
On Wed, Mar 30, 2011 at 11:35 PM, Eli Friedman <eli.friedman at gmail.com> wrote:> On Wed, Mar 30, 2011 at 10:14 AM, Jimborean Alexandra > <xinfinity_a at yahoo.com> wrote: >> Hi, >> >> Is there any method to check if there is a path in the CFG from block M to >> block N, but M does not necessarily dominate block N? >> In other words, if N is reachable from M. > > I don't think there's any method built in to LLVM. It's pretty easy > to write, though. > > -EliA simple depth-first or breadth-first search is good unless you end up querying all pairs - each query is O(blocks + edges), and the number of pairs is O(blocks ^ 2). If you need to answer queries such as "all blocks reachable from X", especially using several X's in the course of an analysis, you'll want more sophisticated algorithms. I found a quick comparison of several algorithms at http://www.seas.upenn.edu/~mengmeng/presentations/reachability.pdf
Seemingly Similar Threads
- [LLVMdev] how to detect if block N is reachable from block M ?
- [LLVMdev] how to detect if block N is reachable from block M ?
- [LLVMdev] How to call the llvm.prefetch intrinsic ?
- [LLVMdev] speculative parallelization in LLVM
- [LLVMdev] speculative parallelization in LLVM