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

Bill Wendling isanbard at gmail.com
Thu Sep 24 01:27:46 PDT 2009


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