[LLVMdev] how to check whether from basicblock A we can go to basicblock B within the same function?

John Criswell criswell at illinois.edu
Fri Aug 27 14:09:32 PDT 2010


Wenbin Zhang wrote:
> Dear all,
> Is there a way to check whether we can go from A to B within a
> function when I'm writing a pass?

I assume you are asking whether control flow can pass from BasicBlock A
to BasicBlock B. In that case, yes: all you need to do is look at the
terminator instruction of BasicBlock A and see if it can branch to
BasicBlock B.

There's a new indirect branch instruction; I don't believe it is used
very often. You might have to handle those specially, but I'll let
others comment on that.

-- John T.

> Thanks.
> Best,
> --Wenbin




More information about the llvm-dev mailing list