[LLVMdev] writing a pass

Misha Brukman brukman at uiuc.edu
Wed Jul 9 11:52:01 PDT 2003


On Wed, Jul 09, 2003 at 10:47:14AM -0500, Nicholas Rizzolo wrote:
> I'm having a problem with opt.  According to the "Writing an LLVM Pass"
> tutorial, all I have to do to get the Hello pass to work is:
> 
>   cd ${LLVM_HOME}/llvm/lib/Transforms/Hello
>   gmake
>   cd $MYTEST
>   opt -load ${OBJ_ROOT}/lib/Release/libhello.so -hello < something.bc > /dev/null

That's pretty much it, assuming a couple of prerequisites, see below.
 
> First (just as a friendly reminder), someone may want to go back and
> double check a bunch of the command lines given in these tutorials. It
> looks like the opt tool, for instance, doesn't take its input from STDIN.

It always has, and still does (at least for me). In addition, it will
take the last command-line parameter as an input filename, if it's not a
command-line switch. If you have a specific problem, please give me a
specific command-line that does not work as it claims to in the
tutorial, and we'll look into it.

> Also, I don't have a Debug subdirectory like the tutorial said I would - I
> have Release instead.

1. What version of LLVM are you using (i.e., when did you get a tarball,
   or if you are using anonymous CVS, are you up to date)?
2. Did you run 'make' or 'make ENABLE_OPTIMIZED=1' or 'make
   ENABLE_PROFILING=1'?
3. If you are using a version of LLVM that is new enough to have a
   'configure' script in the top-level directory, how did you run
   'configure'? You may have specified './configure --enable-optimized'
   or the like, with the save effects as in #2.
 
> That aside, although opt doesn't report any errors when loading
> libhello.so, it also doesn't let me do anything with it:
> 
>   Unknown command line argument '-hello'.  Try: opt --help'
>
> I tried loading the library and specifying '-help' and the '-hello'
> transformation was not listed.  Any idea what I'm doing wrong?
 
I'm assuming that the file `hello.so' does in fact exist. Did you
register your optimization pass with OPT by using something along the
lines of

  RegisterOpt<Hello> X("hello", "Hello World Pass");

as is mentioned in the `Basic code required' section?

I can't think of much else right now, if none of this helps, please
answer my questions as to the `freshness' of your LLVM tree, and send me
your hello pass for inspection.

-- 
Misha Brukman :: http://misha.brukman.net



More information about the llvm-dev mailing list