[LLVMdev] Running a pass

Rahul Joshi rujoshi at uiuc.edu
Wed Aug 13 16:57:01 PDT 2003


Hi,

I assume that since each pass is in its own anonymous
namespace, we cannot directly create a new pass object;
looking at the code for 'opt' utility, it seems we need a
PassInfo object, using which we create a new pass object.
I tried the following code (which I wrote after looking at
the code for bugpoint), but the list of passes seems to be
empty:

// Create a list of all the registered passses
static cl::list<const PassInfo*, bool, PassNameParser>
PassList(cl::desc("Passes available:"), cl::ZeroOrMore);


mem2reg_pass = NULL;
for(It i = PassList.begin(); i != PassList.end(); i++) {
   std::cout << (*i)->getPassName() << endl;
   if(string("mem2reg") == (*i)->getPassName()) {
      mem2reg_pass = *i;
      break;
    }
}
assert(mem2reg_pass);
assert(mem2reg_pass->getNormalCtor());

The first assert always fails, and none of the pass names
appear on the output. So how can I obtain a pointer to the
pass I want to run, so that I can use the pass manager?


>I'm not sure what is causing this problem, if main is not even executing
>yet, then it shouldn't matter what your main does.  :)

This is apparently caused by the linking the 'ipo' library.
I removed that from my Makefile, and it does not happen any
more.

Thanks,
Rahul



More information about the llvm-dev mailing list