Hello David, Thanks for the reply. Would i not need to pass any arguments for viewCFGOnly() method? According to this http://llvm.org/doxygen/Function_8h-source.html seems like we need to? I am building it on top of the example shown at http://llvm.org/docs/WritingAnLLVMPass.html and just added 'F->viewCFGOnly(); line to it. It doesn't compile, i suspect it has to do with the way i am compiling (i thought i solved this). I want to make sure if what i am doing below (code wise) is correct and that the result should be a CFG for the function. My code: #include "llvm/Pass.h" #include "llvm/Function.h" using namespace llvm; namespace { struct Hello : public FunctionPass { static char ID; Hello() : FunctionPass(&ID) {} virtual bool runOnFunction(Function &F) { llvm::cerr << "Hello: " << F.getName() << "\n"; F->viewCFGOnly(); return false; } }; char Hello::ID = 0; RegisterPass<Hello> X("hello", "Hello World Pass"); } Thanks. David Stuttard wrote:> > You can call the function from your program OR the debugger. The > comments simply inform you that it is quite handy to be able to call the > function from a debugger (such as gdb). > > To call the function in you code simply add a line such as: > F->viewCFGOnly(); > Where F is an appropriate variable eg. a MachineFunction pointer > > If you are using gdb then you can do the following: > call F->viewCFGOnly() > > from a point where F is live. > > David >-- View this message in context: http://www.nabble.com/viewCFGOnly%28%29-function-tp24593079p24619824.html Sent from the LLVM - Dev mailing list archive at Nabble.com.
Here's what the doxygen page has for viewCFGOnly() : /// viewCFGOnly - This function is meant for use from the debugger. It works /// just like viewCFG, but it does not include the contents of basic blocks /// into the nodes, just the label. If you are only interested in the CFG /// this can make the graph smaller. /// void viewCFGOnly() const; Which indicates that no arguments are necessary. You're getting a compile error because you are using F->viewCFGOnly() when F is not a pointer in your example. Try F.viewCFGOnly() instead David nxer wrote:> Hello David, > > Thanks for the reply. Would i not need to pass any arguments for > viewCFGOnly() method? According to this > http://llvm.org/doxygen/Function_8h-source.html seems like we need to? > > I am building it on top of the example shown at > http://llvm.org/docs/WritingAnLLVMPass.html and just added > 'F->viewCFGOnly(); line to it. It doesn't compile, i suspect it has to do > with the way i am compiling (i thought i solved this). I want to make sure > if what i am doing below (code wise) is correct and that the result should > be a CFG for the function. > > My code: > > #include "llvm/Pass.h" > #include "llvm/Function.h" > > using namespace llvm; > > namespace { > struct Hello : public FunctionPass { > > static char ID; > Hello() : FunctionPass(&ID) {} > > virtual bool runOnFunction(Function &F) { > llvm::cerr << "Hello: " << F.getName() << "\n"; > F->viewCFGOnly(); > return false; > } > }; > > char Hello::ID = 0; > RegisterPass<Hello> X("hello", "Hello World Pass"); > } > > > Thanks. > > > David Stuttard wrote: >> You can call the function from your program OR the debugger. The >> comments simply inform you that it is quite handy to be able to call the >> function from a debugger (such as gdb). >> >> To call the function in you code simply add a line such as: >> F->viewCFGOnly(); >> Where F is an appropriate variable eg. a MachineFunction pointer >> >> If you are using gdb then you can do the following: >> call F->viewCFGOnly() >> >> from a point where F is live. >> >> David >> >-- Notice The information in this message is confidential and may be legally privileged. It is intended solely for the addressee. Access to this message by anyone else is unauthorized. If you are not the intended recipient, any disclosure, copying or distribution of the message, or any action taken by you in reliance on it, is prohibited and may be unlawful. If you have received this message in error, please delete it and contact the sender immediately. Thank you. 3DLabs Ltd company number 02883883 registered in England and Wales at 79 Knightsbridge, London SW1X 7RB
Oops, should have been clearer, i meant to use a method viewCFGOnly() in Function.h, i thought we need to declare a function variable first (llvm::Function* F) and use the create method, etc. I just confused myself there so i just restarted with clean slate with MachineFunction and this is what i have: #include <stdint.h> #include <stdio.h> #include <llvm/Function.h> #include "llvm/CodeGen/MachineFunction.h" using namespace llvm; int main( int argc, char ** argv ) { llvm::MachineFunction* F; F->viewCFGOnly(); return 0; } I compile it using this: llvm-g++ test.cpp `llvm-config --cxxflags --ldflags --libs` It compiles fine but then what? I have "dot" and "gv" in my path, i thought there would be an empty graph or something that would display. I am not sure if i misunderstood this whole thing. As you can probably tell i am bit a noob with this so could you please point to the right documentation? I am just piecing information together from random parts! Thanks. David Stuttard wrote:> > Here's what the doxygen page has for viewCFGOnly() : > > /// viewCFGOnly - This function is meant for use from the debugger. It > works > /// just like viewCFG, but it does not include the contents of basic > blocks > /// into the nodes, just the label. If you are only interested in the CFG > /// this can make the graph smaller. > /// > void viewCFGOnly() const; > > Which indicates that no arguments are necessary. > > You're getting a compile error because you are using F->viewCFGOnly() when > F is not a > pointer in your example. > > Try F.viewCFGOnly() instead > > David >-- View this message in context: http://www.nabble.com/viewCFGOnly%28%29-function-tp24593079p24638442.html Sent from the LLVM - Dev mailing list archive at Nabble.com.