Hi Chris,
Hi. FYI, it's usually better to email the llvmdev list with generic llvm questions.
Is it possible to get control flow graph of the application with the llvm
infrastructure in terms of basic blocks?
Yes, given a BasicBlock*, you can iterate over the pred/succ blocks in the CFG like this:
#include "llvm/Support/CFG.h"
for (pred_iterator PI = pred_begin(BB), E = pred_end(BB); PI != E; ++PI) {
BasicBlock *OnePredecessor = *PI;
...
For successors, s/pred/succ/
Is there any way of viewing the
Control flow graph of the application.
Yes, use:
analyze -print-cfg X.(bc|ll)
or:
analyze -print-cfg-only X.(bc|ll)
These will emit "dot" files that can be turned into a variety of graphics formats with the graphviz toolset that you can get on the net.
If you're running on a system with graphviz installed and with 'gv' (ghostview), you can even call functions like this from your code or from the debugger:
LLVMFunction->viewCFG()
also ->viewCFGOnly();
Also, when I compile a C file to llvm assembly code i.e using llvmgcc -S
option then the output file has lot of "declare" and "typedef" and then
the "main" starts. Sorry for my naive questions but can you tell me what
are those.
I wouldn't suggest looking at this code. This is the raw output of the C front-end and has not been cleaned up at all. I would suggest using 'llvm-gcc -c', and using llvm-dis on the '.o' file.
Any document which I can go through so that I can understand
the llvm assembly file better.
http://llvm.cs.uiuc.edu/docs/LangRef.html
Actually I am trying to generate VLIW words looking at the assembly file of llvm. Is it possible to do that??
Sure, you can either write your own code generator (not recommended) or port the target independent code generator to your target (described in the docs). We currently have no specific support for VLIW targets, but it should not be difficult to add (and can probably be shared with the IA64 target).
-Chris