How can I identify a backedge from a BasicBlock in LLVM

I am writing an LLVM pass which analyzes and modifies the generated IR code. Is there a way to identify backedges, I mean to know if a successor of a BasicBlock is actually somewhere above it in path.


Yes, there is.

First, note that you need to distinguish between "every path to BB must pass through A", and "there is some path from A that might lead to BB".

I think that you're looking for the first situation - tell if the successor A of the basic block BB is a basic block that the execution must pass through to get to B.

When this situation happens, we say that "A dominates B". The interface to check for dominance is through the DominatorTree class (add in in the getAnalysisUsage function of your pass. See the writing an llvm pass for an example).

Need Your Help

Iterating through a list of lists?

c# silverlight list functional-programming

I have Items from a certain source (populated from somewhere else):

How can change the window title position xaml

wpf xaml window title

Is it possible to change the position of the title in the window? By default it is placed at the left side of the window title bar. I want to move it towards the center.