Question on parameters in RegisterPass

Hello. This is Byungchan An.
I have a question on meaning of parameters in RegisterPass.

In the LLVM Pass examples, I see the followings.

static RegisterPass<Hello> X("hello", "Hello World Pass",
                             false /* Only looks at CFG */,
                             false /* Analysis Pass */);

Here I have one question, what means by only looking at CFG?
If I set it third parameters as “true” what limitations I have?

Second, the last parameter, Analysis Pass means it doesn’t change IR given as input. Am I right? Then, why the following example I got from the llvm website set the last parameter as false?


#include "llvm/Pass.h"
#include "llvm/IR/Function.h"
#include "llvm/Support/raw_ostream.h"

using namespace llvm;

namespace {
  struct Hello : public FunctionPass {
    static char ID;
    Hello() : FunctionPass(ID) {}

    virtual bool runOnFunction(Function &F) {
      errs() << "Hello: ";
      errs().write_escaped(F.getName()) << '\n';
      return false;

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

Dear Byungchang,

The OnlyCFG parameter tells the LLVM PassManager whether your pass modifies a function's control-flow graph (CFG) (i.e., does your pass change the branches between basic blocks or add or remove basic blocks). The PassManager can avoid re-running analysis passes in some cases if the CFG is left unmodified. If you're unsure of what to put in this field, put false.

Setting the AnalysisPass option to true tells the PassManager that your pass never modifies the program. If it is set to false, a pass *may* modify the program (but it is not required to do so). If in doubt, set this to false.


John Criswell