[LLVMdev] How to extract the starting address of each basic block with llvm?

Petsas Athanasios petsas at ics.forth.gr
Fri Mar 28 10:15:09 PDT 2014


Dear all,

I use the clang frontend to produce the control flow graph of a C program
through
this command:
clang -Xclang -analyze -Xclang -analyzer-checker=debug.DumpCFG test.c

The produced information contains all the basic blocks identified by labels,
e.g. B1, B2, etc. along with their predecessors and successors.

Is there a way to get the starting address of each of these basic block?
I would like to map the basic block labels produced by CFG  with the actual
corresponding basic block starting addresses.

Could I use llvm to do this? From what I understand this issued is
unrelevant with
IR. Maybe I could get something from the machine code (MC). Perhaps
I have to write a pass for llvm backend. Maybe I could get this information
from
BranchFolder and IfConverter machine function passes:
http://llvm.org/docs/WritingAnLLVMBackend.html#branch-folding-and-if-conversion
but I am not sure.

I am new to llvm so I need some help,

Thank you,

-- 
Thanasis Petsas
Distributed Computing Systems (DCS)
Institute of Computer Science (ICS/FORTH)
Heraklion, Crete
Greece (GR)

http://www.thanasispetsas.com/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140328/116b42f8/attachment.html>


More information about the llvm-dev mailing list