[LLVMdev] Given Filename and line number, how to get its basicblock?

Devang Patel devang.patel at gmail.com
Thu Sep 24 09:30:45 PDT 2009

On Wed, Sep 23, 2009 at 10:37 PM,  <hc2428 at columbia.edu> wrote:
> Dear developers,
>     Here I met a question: if I got a file called foo.c, and I want
> to know which BasicBlock contains the 30 th line in foo.c, how can I
> get this BasicBlock in LLVM?

You can get line number info for a basic block using findBBStopPoint()
from DebugInfo.h. So one way to get what you want is to iterate over
all the basic blocks and find the basic block that you want. Note, to
get this info, you need to generate llvm IR with debugging information
(e.g. use -g on llvm-gcc command line).


More information about the llvm-dev mailing list