[LLVMdev] viewCFGOnly() function

nxer nxer44 at gmail.com
Wed Jul 22 23:08:20 PDT 2009

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";
      return false;

  char Hello::ID = 0;
  RegisterPass<Hello> X("hello", "Hello World Pass");


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.

More information about the llvm-dev mailing list