Rajendra
2012-Sep-28 11:46 UTC
[LLVMdev] [LLVM-Clang CFG] - generating CFG of a C program and llvm iterators
Hi, I want to generate Control Flow Graph (in memory CFG object) of any given C program and then iterate over this CFG (all function, basic blocks and instructions) using llvm iterators. I can see text output of CFG on screen, using following command: `clang -cc1 -Idummyh -analyze -analyzer-checker=debug.DumpCFG hello/hello.c' where dummyh has en empty stdio.h to remove this error: `fatal error: 'stdio.h' file not found' I see CFG.h and CFG.cpp that clang uses and have seen some docs on ModulePass, FunctionPass, BasicBlockPass, etc. But I have not figured out how to put together things to generate CFG and then write iterators. All help is much appreciated. Thank you. Rajendra
Duncan Sands
2012-Sep-28 15:45 UTC
[LLVMdev] [LLVM-Clang CFG] - generating CFG of a C program and llvm iterators
Hi Rajendra, you want to get hold of the LLVM IR produced by clang (use the -flto option to have clang produce LLVM IR), and pipe it to the "opt" command line tool, into which you will have loaded your logic as a plugin pass. So I suggest you read about writing plugins for opt. Ciao, Duncan.> Hi, > > I want to generate Control Flow Graph (in memory CFG object) of any > given C program and then iterate over this CFG (all function, basic > blocks and instructions) using llvm iterators. > > I can see text output of CFG on screen, using following command: > `clang -cc1 -Idummyh -analyze -analyzer-checker=debug.DumpCFG hello/hello.c' > where dummyh has en empty stdio.h to remove this error: > `fatal error: 'stdio.h' file not found' > > I see CFG.h and CFG.cpp that clang uses and have seen some docs on > ModulePass, FunctionPass, BasicBlockPass, etc. But I have not figured > out how to put together things to generate CFG and then write iterators. > > All help is much appreciated. > > Thank you. > > Rajendra > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Seemingly Similar Threads
- [LLVMdev] LLVM IR and CFG
- [LLVMdev] getting pointer to CFG object for any given C program
- [LLVMdev] [LLVM-Clang CFG] - generating CFG of a C program and llvm iterators
- Help on configuring the samba
- [LLVMdev] How to extract the starting address of each basic block with llvm?