On Fri, 17 Jun 2005, Manvi Agarwal wrote:> 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 -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Manvi Agarwal wrote:> Hi, > > I have generated llvm assembly file using following commands: > llvm-ld main.o fir.o > llvm-dis a.out.bc > > I get a.out.ll as the llvm assembly file. When i go through this assembly > file I come across the following code > fir.entry: ; preds = %loopexit.1.i > call void %print( sbyte* getelementptr ([2 x sbyte]* %.str_3, int > 0, int 0), float* getelementptr ([97 x float]* %y, int 0, int 0), int 97 ) > call void %exit( int 0 ) > unreachable > > > Can anybody please tell me what is meant by "unreachable"? The output is > coming fine.The unreachable instruction tells the LLVM compiler that the statement cannot be reached. It allows LLVM to optimize the program more aggressively. In this case, the unreachable instruction was probably inserted by the LLVM GCC frontend because it knows that the call to exit() will never return. -- John T.> > Regards, > manvi > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-- John T. Criswell Research Programmer University of Illinois at Urbana-Champaign "It's today!" said Piglet. "My favorite day," said Pooh.
Hi, I have generated llvm assembly file using following commands: llvm-ld main.o fir.o llvm-dis a.out.bc I get a.out.ll as the llvm assembly file. When i go through this assembly file I come across the following code fir.entry: ; preds = %loopexit.1.i call void %print( sbyte* getelementptr ([2 x sbyte]* %.str_3, int 0, int 0), float* getelementptr ([97 x float]* %y, int 0, int 0), int 97 ) call void %exit( int 0 ) unreachable Can anybody please tell me what is meant by "unreachable"? The output is coming fine. Regards, manvi
On Fri, Aug 12, 2005 at 01:16:39PM -0500, Manvi Agarwal wrote:> Is it possible to generate a data dependence graph of llvm assembly > file?I am not aware of a general framework for data dependence analysis in LLVM. It's been talked about, but hasn't (yet) been implemented.> How can I get the data flow information in X.ll file?LLVM assembly is in SSA, data flow (use-def and def-use chains) is explicit. What exactly are you looking for?> Also, in .ll file I see everyline ends with something like this: > <type> [#uses=3] What is the significance of this and is it used > anyway by the compiler for data dependence analysis.Since it follows the semicolon ';' it's an LLVM comment and ignored by llvm-as and gccas. However, it's not any extra information -- LLVM is fully-typed so the <type> is the type of the statement on the line it appears, and since def-use chains are explicit in LLVM (see above), the # uses is also explicit in the code, so it's not any extra information that isn't present already, either. This paper is a good introduction to LLVM: http://llvm.cs.uiuc.edu/pubs/2004-01-30-CGO-LLVM.html -- Misha Brukman :: http://misha.brukman.net :: http://llvm.cs.uiuc.edu
Hi, Is it possible to generate a data dependence graph of llvm assembly file? How can I get the data flow information in X.ll file? Also, in .ll file I see everyline ends with something like this: <type> [#uses=3] What is the significance of this and is it used anyway by the compiler for data dependence analysis. I would be grateful for any help. Regards, Manvi
> Is it possible to generate a data dependence graph of llvm assembly file? > How can I get the data flow information in X.ll file? Also, in .ll file I > see everyline ends with something like this: > <type> [#uses=3] > What is the significance of this and is it used anyway by the compiler for > data dependence analysis.There is no general framework at the moment. I wrote some basic data dependence analysis stuff for my research with software pipelining, but unfortunately its somewhat Sparc specific at the moment. You can take a look at: lib/Target/SparcV9/ModuloScheduling/MSchedGraph.h lib/Target/SparcV9/ModuloScheduling/MSchedGraph.cpp lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.cpp lib/Target/SparcV9/ModuloScheduling/DependenceAnalyzer.h Eventually it should be target independent, but some additional pieces to the puzzle need to fall in place first. -Tanya