hc2428 at columbia.edu
2009-Sep-24 05:37 UTC
[LLVMdev] Given Filename and line number, how to get its basicblock?
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? Thanks, Heming
Bill Wendling
2009-Sep-24 08:27 UTC
[LLVMdev] Given Filename and line number, how to get its basicblock?
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
hc2428 at columbia.edu
2009-Sep-24 15:54 UTC
[LLVMdev] Given Filename and line number, how to get its basicblock?
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? Heming> 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
Devang Patel
2009-Sep-24 16:30 UTC
[LLVMdev] Given Filename and line number, how to get its basicblock?
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). - Devang
Apparently Analagous Threads
- [LLVMdev] Given Filename and line number, how to get its basicblock?
- [LLVMdev] A basicblock iterator bug in llvm
- [LLVMdev] DataStructure Analysis ds-aa can not stop when passing mysqld
- [LLVMdev] Is it possible to map an LLVM instruction to x86 assembly instructions?
- [LLVMdev] Error when running llc to compile .bc to .s