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

hc2428 at columbia.edu hc2428 at columbia.edu
Thu Sep 24 08:54:50 PDT 2009

Quoting Bill Wendling <isanbard at gmail.com>:

Dear Bill,
     Thanks very much for your reply. Does it mean that currently I  
can only collect all dbg-point-instructions in *.bc and maintain these  
information by myself?
     Devang's work seems promissing, when can it be ready? Will  
llvm-2.6 incorporate this feature?


> On 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?
> Hi Heming,
> The only way I can think of to do this is to look at the debug
> information. Devang's been hard at work recoding the debug info
> infrastructure to use metadata nodes instead of the current clunky
> model. With that, you should be able to look at all instructions,
> determine from the metadata which line it's at, and then from the
> instruction you can get the basic block that contains the particular
> line.
> -bw

More information about the llvm-dev mailing list